Meta annotation input (OverridesAttribute) is ignored
See original GitHub issueHello,
i am using springfox 2.9.2 and writing a meta annotation with Size:
@Pattern(regexp="[a-z]*")
@Size
@Target({FIELD, TYPE, PARAMETER })
@Retention(RUNTIME)
@Constraint(validatedBy = {})
public @interface MyVerify {
@OverridesAttribute(constraint = Pattern.class, name = "message")
String message() default "Wrong text";
@OverridesAttribute(constraint = Size.class, name = "min")
int min()default 5;
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
And using it in model:
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MyInfo {
private int age;
@MyVerify(min = 6)
private String someText;
}
And the rest controller using the model:
@RequestMapping(value = "/info", method = RequestMethod.POST)
public MyInfo someInfo(@RequestBody @Valid MyInfo myInfo){
myInfo.setAge(99);
return myInfo;
}
Java will enforce the MyVerify limit with min 5 chars if i will try to post wrong data, but the swagger file will ignore it and will use the min and max value of the Size annotation (0,2147483647):
"definitions": {
"MyInfo": {
"type": "object",
"properties": {
"age": {
"type": "integer",
"format": "int32"
},
"someText": {
"type": "string",
"minLength": 0,
"maxLength": 2147483647,
"pattern": "[a-z]*"
}
},
"title": "MyInfo"
}
}
The issues will repeat itself if i will use annotation with input:
MyVerify(min = 99, max = 200)
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Java annotation that summarizes other annotations
JPA 2.2 supports "meta-annotations" as per this link. Then it comes down to whether your JPA provider supports JPA 2.2 or not (the...
Read more >Support Java custom meta-annotations to selectively ignore ...
In our code base, the objects exchanged via our REST API are defined as classes (views) with all fields public, no constructor (i.e....
Read more >Hibernate Validator 8.0.0.Final - Jakarta Bean Validation ...
The default metadata source are annotations, with the ability to override and extend the meta-data through the use of XML.
Read more >Bean Validation specification
Any groups definition on a composing annotation is ignored. Payload from the main constraint annotation is inherited by the composing ...
Read more >Nullable meta annotations are ignored · Issue #973 - GitHub
Describe the feature JSR 303 allows for creating a constraint composition and it seems to not be supported. I can see the code...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had recent activity. Please re-open a new issue if this is still an issue.