-
-
Notifications
You must be signed in to change notification settings - Fork 523
Fix behaviuor of required flag for schema class fields. #2185
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
Comments
Would you be able to propose a PR respecting the test cases you mentioned ? |
Fair point, I'll see what I can do. |
bnasslahsen
added a commit
that referenced
this issue
Apr 1, 2023
I have added the requested fix. Let me know if that works for you. You can test it with the latest SNAPSHOT and let us know. |
Yes that looks spot on. Thanks for the quick turn around! 🙌 |
mikehalmamoj
added a commit
to ministryofjustice/hmpps-activities-management-api
that referenced
this issue
Apr 2, 2023
matt-crowson-moj
pushed a commit
to ministryofjustice/hmpps-activities-management-api
that referenced
this issue
Apr 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
In schema generated from Kotlin classes the required flag defaults to false even if the type is non-nullable. This contradicts the openapi-generator which uses the required flag to determine whether a generated property is nullable.
To Reproduce
Steps to reproduce the behavior:
This will generate a field that is not required. It should be required as it is non-nullable.
3.0.5
org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.4
Expected behavior
When deciding if a field is required we need to consider the Schema annotation required attribute, the type of the field and whether there is a default value.
If there is a schema required value then respect that.
If not then required is true for non-nullable and false for nullable.
Except non-nullable with a default value for which required = false.
I would suggest the following test cases:
The text was updated successfully, but these errors were encountered: