-
Notifications
You must be signed in to change notification settings - Fork 45
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
A model unioned with null introduces inheritance #1163
Comments
A more generic question here is how to interpret
According to Bar:
type: object
required:
- test
properties:
test:
$ref: '#/components/schemas/Foo'
nullable: true Another translation may introduce un-necessary inheritance, it would act as allowing properties:
test:
type: object
allOf:
- $ref: '#/components/schemas/Foo'
nullable: true |
I would note that Now deviate from teh actual spec and we do allow certain sibling properties next to $ref so we could see to try to flatten in this case. |
From SDK's perspective it is a breaking change especially you already pointed out that "we interpreted it as inheritance for swagger". We could correctly generate dictionary properties as Not sure what other generates, but .net generates |
@markcowl @timotheeguerin I understand there might be no better solution. I created this to explore if we could figure out a better one. If we finally don't have one, I think we should at least have a "known issue" section somewhere. |
autorest flatten those cases, they result in the exact same codemodel as it is needed to represent openapi3 spec that are compliant. |
@timotheeguerin Is saying that AutoRest treats these two cases as the same in code model, so how would our autorest-based generators do anything different for these? Similarly, emitters can choose how they treat |
I can understand from openapi3's side they are compliant. We do have a difference with generated name in codemodel,
The interesting part is the option 1 is not a standard OpenAPI spec because atributes next of a $ref must be ignored. However, autorest has allowed it. And the option 2 looks more correct spec but it has no way to indicate the nullable object name, so autorest generated one automatically. Does that mean the autorest and openapi3 may have difference when handling nullable objects? But i think this is not what we want. |
I don't understand why you say there is a difference in the codemodel, I tried autorest WILL flatten option2 to produce the same thing as option1. Can you show a repro where it is different. And yeah option 1 is NOT compliant for openapi 2.0 and openapi 3.0. It is in openapi 3.1, this is something autorest decided to do to make things simpler. And yeah in general we try to make it emit option 1 when possible in the autorest emitter but always option 2 in openapi3. |
I tried these two examples with
in autorest.csharp.
|
hhm ok I don't know then if there was an option or what that made this work but either way we usually flatten |
I think no. We could put aside till there is a real case. |
Closing until we have a real service example. |
This triggers when using
|
This is what we found from the unmerged pipeline. We found this change. The problem comes from this ManagedServiceIdentity.userAssignedIdentities whose type is
Record<UserAssignedIdentity | null>
.See this playground, as long as a model is "unioned" with a
null
, its type is changed to anallOf
. See the difference betweenproperty2
andproperty3
inB
. This is not accurate,The text was updated successfully, but these errors were encountered: