Forum Discussion
OAS 3.0 is supported by `swagger-api` `swagger-maven-plugin` (latest release `2.0.8`), please check https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-maven-plugin and related projects (wiki)
- cmu6 years agoNew Contributor
Thank you. I am working on it. I need Swagger Hibernate Validations and looking for one in Maven repo, but I can't find one exact for io.swagger.core.v3 even though I searched in that group. Any idea where can I get this.
- frantuma6 years agoStaff
in v3 possibly the best option to process hibernate validation annotations (or any other/custom annotations) is to provide a custom resolver with the logic you need; here is an example handling e.g. Length annotation (extend it to apply to whatever annotations you need):
class CustomConverter extends ModelResolver {
public CustomConverter(ObjectMapper mapper) {
super(mapper);
}
@Override
protected void applyBeanValidatorAnnotations(Schema property, Annotation[] annotations, Schema parent) {
super.applyBeanValidatorAnnotations(property, annotations, parent);
Length lengthAnn = AnnotationsUtils.getAnnotation(Length.class, annotations);
if (lengthAnn != null) {
if (lengthAnn.min() != 0) property.setMinimum(new BigDecimal(lengthAnn.min()));
if (lengthAnn.max() < Integer.MAX_VALUE) property.setMaximum(new BigDecimal(lengthAnn.max()));
}
}
}when using the maven plugin you can configure such custom converter using modelConverterClasses configuration property, setting it to fully qualified class name (e.g. foo.bar.CustomConverter). Please check also related wiki
Related Content
- 2 years ago
- 3 years ago