-
Notifications
You must be signed in to change notification settings - Fork 23
feat(openapi-generator): Allow for primitives in anyOf/oneOf component schema definitions #681
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
Conversation
CharlesDuboisSAP
left a comment
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
| <useOneOfCreators>true</useOneOfCreators> | ||
| <enumUnknownDefaultCase>true</enumUnknownDefaultCase> | ||
| </additionalProperties> | ||
| <enableOneOfAnyOfGeneration>true</enableOneOfAnyOfGeneration> |
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.
Why were the other classes (OneOf, AnyOf) not affected by this change?
Why wasn't it there in the first place?
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.
Omg, I went deep into the rabbit hole. I found that our check for (unsupported) anyof / oneof was not sufficient!
oneOfandanyOfare not checked when they are part of schema root; only when they are deeper in object hierarchy, e.g. when being part ofpropertiesfields
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 think this was intentional, because on the root level the generation was already working for some cases. IIRC
# Conflicts: # datamodel/openapi/openapi-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/OneOfDeserializationTest.java # datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/oneof_interface.mustache

Context
https://github.tools.sap/AI/ai-sdk-java-backlog/issues/129
Enable this kind of specification:
components: schema: Fanta: type: object properties: sodaType: type: string + flavor: + oneOf: + - type: string + - type: integer + - type: array + items: + type: string + - type: object + properties: + foo: string + bar: integerto generate the code that compiles and allows for deserialization:
Known limitations:
JsonCreator.Feature scope:
Add feature toggle
useOneOfCreatorsDefinition of Done
Error handling created / updated & covered by the tests aboveDocumentation updatedRelease notes updated(internal feature toggle)