From fb115abd62fede31a07c8a9630dadeb2c2e4b2ed Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 13 Sep 2020 20:29:43 +0200 Subject: [PATCH] JAVA-2400: Fix EmailAnnotationPlugin implementation --- .../baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java index 22ca144fb4..59a7c97080 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/plugin/EmailAnnotationPlugin.java @@ -10,6 +10,7 @@ import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import springfox.bean.validators.plugins.Validators; +import springfox.documentation.builders.StringElementFacetBuilder; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.schema.ModelPropertyBuilderPlugin; import springfox.documentation.spi.schema.contexts.ModelPropertyContext; @@ -30,8 +31,9 @@ public class EmailAnnotationPlugin implements ModelPropertyBuilderPlugin { public void apply(ModelPropertyContext context) { Optional email = annotationFromBean(context, Email.class); if (email.isPresent()) { - context.getBuilder().pattern(email.get().regexp()); - context.getBuilder().example("email@email.com"); + context.getSpecificationBuilder().facetBuilder(StringElementFacetBuilder.class) + .pattern(email.get().regexp()); + context.getSpecificationBuilder().example("email@email.com"); } }