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

[OpenAPI] case class field being an Option of an ADT are not rendered as nullable #3053

Merged
merged 5 commits into from
Aug 27, 2024

Conversation

guizmaii
Copy link
Member

Fixes #3052

@guizmaii guizmaii marked this pull request as ready for review August 26, 2024 01:01
@@ -988,7 +988,7 @@ object OpenAPIGen {
}
private def schemaReferencePath(nominal: TypeId.Nominal, referenceType: SchemaStyle): String = {
referenceType match {
case SchemaStyle.Compact => s"#/components/schemas/${nominal.typeName}}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +3064 to +3069
| "optionalAdtField" : {
| "anyOf": [
| { "type": "null" },
| { "$ref": "#/components/schemas/SealedTraitCustomDiscriminator" }
| ]
| }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now correctly have the anyOf

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, if this should be anyOf, or if the field should just be missing from the required fields list. I'd tend to the second. Most Scala json serialization does not write the field if the option is None

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe both. To be accept all possible encodings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. They are now both nullable and non-required

@jdegoes jdegoes merged commit 972e01a into main Aug 27, 2024
65 checks passed
@jdegoes jdegoes deleted the openapi_nullable_ref branch August 27, 2024 20:39
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] case class field being an Option of an ADT are not rendered as nullable
3 participants