#1857 Use @ApiModelProperty required value if present instead of @NotNull #2606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As stated in #1857, in this situation:
field
lorem
is marked as required, as it has@javax.validation.constraints.NotNull
annotation. This change modifies behavior so if@ApiModelProperty
is present, it will always be used it'srequired
value. Swagger annotations should have precedence over other annotations.Only drawback is that in existing code this:
currently is marked as required (because of
@NotNull
), and after change it will be marked as not-required (asrequired=false
is default value in@ApiModelProperty
).Every other code will act as before, so this:
will be marked as required, since there is no Swagger annotation that would override it.
This change can be done for 2.0 version as well, so if it will be accepted I can make another PR for 2.0. Or maybe this change should go only to 2.0, as it somehow changes previous behavior. Please let me know what do you think.