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

Basic Container Item Annotation Support #61

Merged
merged 4 commits into from
Mar 31, 2020

Conversation

CarstenWickner
Copy link
Member

@CarstenWickner CarstenWickner commented Mar 31, 2020

These changes should cover the majority of use-cases as per #60 for container items.

This is explicitly not covering other generics such as Optional<@NotBlank String>.
Also for collections, this "basic" support is only going "one level deep", i.e.

  • List<@Size(min = 3) String> will now pick-up the "minLength" for the String list items
  • List<List<@Size(min = 3) String>> will not recognize the "minLength" attributes

Since the classmate library used for type resolution currently does not include the AnnotatedType (introduced in Java 8), some additional changes will be required to make this work for more than the first level of container items.
At that time, a more generic approach can be taken to support other parameterized types besides collections.


jsonschema-generator

Added

  • Convenience methods on FieldScope/MethodScope for accessing (first level) container item annotations: getContainerItemAnnotation() and getContainerItemAnnotationConsideringFieldAndGetter()

Changed

  • MethodScope.getAnnotation() now also considers annotations directly on return type (when no matching annotation was found on the method itself)

jsonschema-module-javax-validation

Changed

  • Consider (first level) container item annotations (e.g. List<@Size(min = 3) String>)

@CarstenWickner CarstenWickner added the enhancement New feature or request label Mar 31, 2020
@CarstenWickner CarstenWickner self-assigned this Mar 31, 2020
@CarstenWickner CarstenWickner merged commit edabc93 into master Mar 31, 2020
@CarstenWickner CarstenWickner deleted the improved-container-item-handling branch March 31, 2020 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

1 participant