-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
model extends/is record<> #330
Conversation
🦋 Changeset detectedLatest commit: 47e84d8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I would not put this in inheritance. TSP uses "extends", but it's the concept of "additional properties". Inheritance is misleading here.
- I need a GET as well
note also See the differently generated openapi I don't know how that affect generated client however but I could imagine something like that
|
On swagger output of model ModelRecordUnknown2 is Record<unknown> {
name: string;
} ModelRecordUnknown2:
type: object
additionalProperties: {} It does not have anything about "name"? PS, Java uses composition (it is almost always a bad practice to inherit class WithWhatever() {
string name;
Map<String, Object> additionalProperties; // this does not serialize to JSON, but as a composition for properties except "name"
} |
@timotheeguerin As weidong said, we shall encourage users |
I add new folder |
@msyyc I prefer to add it under to |
Hhm yeah seems like we have a bug in autorest and openapi3 emitter, those properties should not be dropped. I think the idea was there though that with I think the takeaway is mostly both can happen and I think we should recommend people to use the |
there is a discussion on Teams about that short answer, no models do not have additional properties in the TypeSpec system(I made a wrong statement before), we might need to update the type graph a little bit
|
@tadelesh Make sense. I will move it to |
@timotheeguerin @lmazuel @tadelesh @weidongxu-microsoft |
packages/cadl-ranch-specs/http/type/property/additional-properties/mockapi.ts
Outdated
Show resolved
Hide resolved
packages/cadl-ranch-specs/http/type/property/additional-properties/main.tsp
Show resolved
Hide resolved
packages/cadl-ranch-specs/http/type/property/additional-properties/main.tsp
Outdated
Show resolved
Hide resolved
…into extends-record
packages/cadl-ranch-specs/http/type/property/additional-properties/main.tsp
Outdated
Show resolved
Hide resolved
packages/cadl-ranch-specs/http/type/property/additional-properties/mockapi.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor comment
packages/cadl-ranch-specs/http/type/property/additional-properties/main.tsp
Outdated
Show resolved
Hide resolved
packages/cadl-ranch-specs/http/type/property/additional-properties/main.tsp
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor comment
…ties/main.tsp Co-authored-by: Chenjie Shi <tadelesh.shi@live.cn>
packages/cadl-ranch-specs/http/type/property/additional-properties/main.tsp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you've tested the mockapi in python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though seems a little bit weird to give both is
and extends
example, but should all be valid cases for non-branding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was approved by enough smart people to remove my "require change" :)
Cadl Ranch Contribution Checklist:
@scenario
names. Someone can look at the list of scenarios and understand what I'm covering.@scenarioDoc
s for extra scenario description and to tell people how to pass my mock api check.