feat: support declared type as array for jsonSchema #1590
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.
When using Jsr303 annotation, to get our objects fileds checked for constraints, we have to annotate them with
@Valid
, this annotation is added on fileds that aren't premetives (or objects représenting premitives like : Integer) to recursively check constraints.Until now, to annotate a field with this annotation, we check for it's type weither it's
"object"
or"array"
. Since the specification of jsonSchema seems to accept a string or an array of strings, when we use an array of strings the annotation@Valid
is not added to the field, thus, the field is not checked for constraints.for example, in the current version, if we use this jsonShema (which is valid according to specification of jsonschema)
The filed
myField
will not have the annotation@Valid
and it's objects won't be validated.Some links :
PS :
For tests, i have just changed existing tests, please let me know if it's better to duplicate existing tests to cover this new feature even if it's the same as existing one 😃.