-
-
Notifications
You must be signed in to change notification settings - Fork 528
Support for @Positive #3001
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
Support for @Positive #3001
Conversation
@@ -189,6 +190,9 @@ public static boolean fieldRequired(Field field, @Nullable io.swagger.v3.oas.ann | |||
public static void applyValidationsToSchema(Schema<?> schema, List<Annotation> annotations) { | |||
annotations.forEach(anno -> { | |||
String annotationName = anno.annotationType().getSimpleName(); | |||
if (annotationName.equals(Positive.class.getSimpleName())) { | |||
schema.setMinimum(BigDecimal.ONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value BigDecimal.ONE
is valid only for integers.
For decimals, for example, we can have a valid value 0.00001
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the right approach is schema.setExclusiveMinimumValue(BigDecimal.ZERO);
However, according to https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-models/src/main/java/io/swagger/v3/oas/models/media/Schema.java#L441 it is supported only in OpenAPI 3.1.
@bnasslahsen Any reason it was merged? |
@mpleine Are you going to prepare another PR that would fix it for decimals? |
I can see it was fixed in 6c3aa8f |
Added support for @positive annotation validation constraint
When merged, the following documentation should be updated also
Suggestion:
Maybe there could be a complete list in the documentation, which validation annotations are currently supported (and the ones that are not listed there, are currently not supported)