Java Code Examples for org.eclipse.microprofile.openapi.models.media.Schema#getMaximum()

The following examples show how to use org.eclipse.microprofile.openapi.models.media.Schema#getMaximum() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanValidationScanner.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
void decimalMax(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_DECIMAL_MAX);

    if (constraint != null && schema.getMaximum() == null) {
        String decimalValue = stringValue(constraint, VALUE);
        try {
            BigDecimal decimal = new BigDecimal(decimalValue);
            schema.setMaximum(decimal);

            Optional<Boolean> inclusive = booleanValue(constraint, INCLUSIVE);

            if (schema.getExclusiveMaximum() == null && inclusive.isPresent() && !inclusive.get()) {
                schema.setExclusiveMaximum(Boolean.TRUE);
            }
        } catch (@SuppressWarnings("unused") NumberFormatException e) {
            DataObjectLogging.log.invalidAnnotationFormat(decimalValue);
        }
    }
}
 
Example 2
Source File: BeanValidationScanner.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
void max(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_MAX);

    if (constraint != null && schema.getMaximum() == null) {
        AnnotationValue value = constraint.value(VALUE);
        schema.setMaximum(new BigDecimal(value.asLong()));
    }
}
 
Example 3
Source File: BeanValidationScanner.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
void negative(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_NEGATIVE);

    if (constraint != null && schema.getMaximum() == null) {
        Boolean exclusive = schema.getExclusiveMaximum();

        if (exclusive != null && exclusive) {
            schema.setMaximum(BigDecimal.ZERO);
        } else {
            schema.setMaximum(NEGATIVE_ONE);
        }
    }
}
 
Example 4
Source File: BeanValidationScanner.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
void negativeOrZero(AnnotationTarget target, Schema schema) {
    AnnotationInstance constraint = getConstraint(target, BV_NEGATIVE_OR_ZERO);

    if (constraint != null && schema.getMaximum() == null) {
        Boolean exclusive = schema.getExclusiveMaximum();

        if (exclusive != null && exclusive) {
            schema.setMaximum(BigDecimal.ONE);
        } else {
            schema.setMaximum(BigDecimal.ZERO);
        }
    }
}