-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Swagger ignores @Schema(required = true) on non-primitive types when generating the openapi.yaml #3259
Comments
christophercolumbusdog
changed the title
Swagger ignore @Schema(required = true) on non-primitive types
Swagger ignores @Schema(required = true) on non-primitive types when generating the openapi.yaml
Jul 29, 2019
https://stackoverflow.com/questions/51671883/swagger-ignores-schema-properties-for-referenced-schemas |
Is there any progress with this issuse? |
frantuma
added a commit
that referenced
this issue
Mar 22, 2020
frantuma
added a commit
that referenced
this issue
Mar 22, 2020
refs #3259 - fix required annotation processing for reference properties
Thanks for reporting this! eventually fixed in #3482 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a reproducible issue where Swagger will ignore
@Schema(required = true)
annotations on Object fields when generating the openapi.yaml specification.To reproduce this, follow the general steps:
Pet
object, modify the code to look like the following:(Here, we add
@Schema(required = true)
required tags to both the "id" and "category" fields)After following these steps, we see that the generated yaml contains the following:
This is unexpected. I would expect that adding
@Schema(required = true)
to theid
andcategory
fields would add bothid
andcategory
to the "required" section of the Pet yaml. Yet, we only seeid
added. I've tested this in other scenarios, and it seems it only adds the field as "required" if it's some OpenApi primitive (i.e., it does not have a $ref).If you manually add
category
to the "required" section, it will properly show thatcategory
is required in the Swagger UI. But without manually adding it,category
will not have the same red asterisk that the other required fields have.Because of this issue, it's harder to specify what objects in a complex type must be filled out in API requests and which may be omitted. This is especially helpful when using Immutables, as some fields in Immutables will use a default if nothing is specified, while for other fields immutables will throw an exception if it's missing.
The text was updated successfully, but these errors were encountered: