Skip to content
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

Fix OpenAPI 3.0 output of nullable references #2152

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

Azquelt
Copy link
Contributor

@Azquelt Azquelt commented Jan 14, 2025

When a nullable field or parameter references a non-nullable schema, we generate a schema for the field which uses anyOf to permit null. Any informational properties or additional assertions defined on the field are also put on the field schema and the type property is also retained.

When we were transforming this field schema for OpenAPI 3.0, we were only doing certain transformations if the type property is not present, which doesn't handle the case above.

Ensure the transformation to and from OpenAPI 3.0 schemas handles these nullable references which include the type property.

Fixes #2145

@Azquelt
Copy link
Contributor Author

Azquelt commented Jan 14, 2025

Waiting for #2151 to be merged to rebase this.

When a nullable field or parameter references a non-nullable schema, we
generate a schema for the field which uses anyOf to permit null. Any
informational properties or additional assertions defined on the field
are also put on the field schema and the type property is also retained.

When we were transforming this field schema for OpenAPI 3.0, we were
only doing certain transformations if the type property is not present,
which doesn't handle the case above.

Ensure the transformation to and from OpenAPI 3.0 schemas handles these
nullable references which include the type property.
@Azquelt Azquelt force-pushed the schema-nullable-ref-3.0 branch from 49f0e4c to 9e8d58e Compare January 15, 2025 10:25
@MikeEdgar MikeEdgar added this to the 4.0.7 milestone Jan 15, 2025
@Azquelt
Copy link
Contributor Author

Azquelt commented Jan 15, 2025

This has been rebased and is ready for review.

@MikeEdgar
Copy link
Member

Looks good, thanks @Azquelt

@MikeEdgar MikeEdgar merged commit 8e58b30 into smallrye:main Jan 15, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenAPI 3.0.3 Schema Incorrectly Includes enum: [null] When Description is Present in @Schema Annotation
2 participants