-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
[BUG] [ExampleGenerator] Generated examples from Composed schema types are null
(allOf, oneOf, anyOf...)
#17497
Closed
5 of 6 tasks
Labels
Comments
5 tasks
acouvreur
added a commit
to acouvreur/openapi-generator
that referenced
this issue
Jan 5, 2024
Changes the previous behavior of generating `null` examples for allOf composed schemas. Fixes OpenAPITools#17497
acouvreur
pushed a commit
to acouvreur/openapi-generator
that referenced
this issue
Jan 5, 2024
…hemas Changes the previous behavior of generating `null` examples for anyOf and oneOf composed schemas. To generate a oneOf/anyOf example, we generate the example using the first valid schema available. In case of a $ref, we use the first valid reference. Fixes OpenAPITools#17497
acouvreur
added a commit
to acouvreur/openapi-generator
that referenced
this issue
Jan 5, 2024
Changes the previous behavior of generating `null` examples for allOf composed schemas. Fixes OpenAPITools#17497
acouvreur
added a commit
to acouvreur/openapi-generator
that referenced
this issue
Jan 6, 2024
…hemas Changes the previous behavior of generating `null` examples for anyOf and oneOf composed schemas. To generate a oneOf/anyOf example, we generate the example using the first valid schema available. In case of a $ref, we use the first valid reference. Fixes OpenAPITools#17497
wing328
pushed a commit
that referenced
this issue
Jan 10, 2024
) * fix: ExampleGenerator correctly generates allOf composed schemas Changes the previous behavior of generating `null` examples for allOf composed schemas. Fixes #17497 * fix: ExampleGenerator correctly generates anyOf and oneOf composed schemas Changes the previous behavior of generating `null` examples for anyOf and oneOf composed schemas. To generate a oneOf/anyOf example, we generate the example using the first valid schema available. In case of a $ref, we use the first valid reference. Fixes #17497
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report Checklist
Description
When generating an example for a model defined as a composite schema, such as:
Current (undesired) behavior:
Consider the following schema:
I'd expect the generated example to look like:
However, it currently generates the following:
null
Why is this behavior happening?
It's because only examples and properties are being supported right now:
openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java
Lines 349 to 363 in a5d3fb4
The message
// TODO log an error message as the model does not have any properties
is wrong because composed schema may exist.
openapi-generator version
master a5d3fb4
OpenAPI declaration file content or url
Generation Details
Run ExampleGeneratorTest.java
Steps to reproduce
Apply to following patch:
Related issues/PRs
Suggest a fix
Will open a PR soon
The text was updated successfully, but these errors were encountered: