JAVA-2400: Fix EmailAnnotationPlugin implementation

This commit is contained in:
Krzysiek 2020-09-13 20:29:43 +02:00
parent ed7ce4ce34
commit fb115abd62
1 changed files with 4 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import springfox.bean.validators.plugins.Validators; import springfox.bean.validators.plugins.Validators;
import springfox.documentation.builders.StringElementFacetBuilder;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.schema.ModelPropertyBuilderPlugin; import springfox.documentation.spi.schema.ModelPropertyBuilderPlugin;
import springfox.documentation.spi.schema.contexts.ModelPropertyContext; import springfox.documentation.spi.schema.contexts.ModelPropertyContext;
@ -30,8 +31,9 @@ public class EmailAnnotationPlugin implements ModelPropertyBuilderPlugin {
public void apply(ModelPropertyContext context) { public void apply(ModelPropertyContext context) {
Optional<Email> email = annotationFromBean(context, Email.class); Optional<Email> email = annotationFromBean(context, Email.class);
if (email.isPresent()) { if (email.isPresent()) {
context.getBuilder().pattern(email.get().regexp()); context.getSpecificationBuilder().facetBuilder(StringElementFacetBuilder.class)
context.getBuilder().example("email@email.com"); .pattern(email.get().regexp());
context.getSpecificationBuilder().example("email@email.com");
} }
} }