Class BeanValidationScanner
java.lang.Object
io.smallrye.openapi.runtime.scanner.dataobject.BeanValidationScanner
- Author:
- Michael Edgar <michael@xlate.io>
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyConstraints(AnnotationScannerContext context, org.jboss.jandex.Type type, org.eclipse.microprofile.openapi.models.media.Schema schema) Apply validation constraints found on the type to the schema, if bean validation scanning is enabled on the given context.voidapplyConstraints(org.jboss.jandex.AnnotationTarget target, org.eclipse.microprofile.openapi.models.media.Schema schema, String propertyKey, BeanValidationScanner.RequirementHandler handler) Determine if any Java Bean Validation constraint annotations are present on theAnnotationTargetthat are applicable to the schema.voidapplyConstraints(org.jboss.jandex.Type target, org.eclipse.microprofile.openapi.models.media.Schema schema, String propertyKey, BeanValidationScanner.RequirementHandler handler) LikeapplyConstraints(AnnotationTarget, Schema, String, RequirementHandler), but for constraints onTypes.booleanhasConstraints(org.jboss.jandex.AnnotationTarget target) Scan the annotation target to determine whether any annotations from the Bean Validation package (javax.validation.constraints) are present.
-
Constructor Details
-
BeanValidationScanner
-
-
Method Details
-
hasConstraints
public boolean hasConstraints(org.jboss.jandex.AnnotationTarget target) Scan the annotation target to determine whether any annotations from the Bean Validation package (javax.validation.constraints) are present.- Parameters:
target- the annotation target to scan- Returns:
- true if annotations from the Bean Validation package are present, otherwise false.
-
applyConstraints
public void applyConstraints(org.jboss.jandex.AnnotationTarget target, org.eclipse.microprofile.openapi.models.media.Schema schema, String propertyKey, BeanValidationScanner.RequirementHandler handler) Determine if any Java Bean Validation constraint annotations are present on theAnnotationTargetthat are applicable to the schema. This method will apply the constraints to the schema only if no value has previously been set. If the schema's type attribute has not been previously set or the schema contains a reference, this method will not apply any changes to the schema. Each of the constraints (defined in javax.validation.constraints) will apply to the schema based on the schema's type. When a bean validation @NotNull constraint applies to the schema, the providedBeanValidationScanner.RequirementHandlerwill be called in order for the component calling this method to determine if and how to apply the requirement. E.g. a required Schema is communicated differently for a parent schema and for a parameter described by the schema.- Parameters:
target- the object from which to retrieve the constraint annotationsschema- the schema to which the constraints will be appliedpropertyKey- the name of the property in parentSchema that refers to the schemahandler- the handler to be called when a bean validation @NotNull constraint is encountered.
-
applyConstraints
public void applyConstraints(org.jboss.jandex.Type target, org.eclipse.microprofile.openapi.models.media.Schema schema, String propertyKey, BeanValidationScanner.RequirementHandler handler) LikeapplyConstraints(AnnotationTarget, Schema, String, RequirementHandler), but for constraints onTypes.- Parameters:
target- the object from which to retrieve the constraint annotationsschema- the schema to which the constraints will be appliedpropertyKey- the name of the property in parentSchema that refers to the schemahandler- the handler to be called when a bean validation @NotNull constraint is encountered.
-
applyConstraints
public static void applyConstraints(AnnotationScannerContext context, org.jboss.jandex.Type type, org.eclipse.microprofile.openapi.models.media.Schema schema) Apply validation constraints found on the type to the schema, if bean validation scanning is enabled on the given context.- Parameters:
context- current scanning contexttype- the object from which to retrieve the constraint annotationsschema- the schema to which the constraints will be applied
-