4040import javax .validation .constraints .DecimalMin ;
4141import javax .validation .constraints .Max ;
4242import javax .validation .constraints .Min ;
43- import javax .validation .constraints .NotNull ;
4443import javax .validation .constraints .Pattern ;
4544import javax .validation .constraints .Size ;
4645
@@ -96,17 +95,17 @@ public abstract class AbstractRequestService {
9695 * The constant ANNOTATIONS_FOR_REQUIRED.
9796 */
9897// using string litterals to support both validation-api v1 and v2
99- private static final String [] ANNOTATIONS_FOR_REQUIRED = { NotNull . class . getName () , "javax.validation.constraints. NotBlank" , "javax.validation.constraints. NotEmpty" };
98+ private static final String [] ANNOTATIONS_FOR_REQUIRED = {" NotNull" , "NonNull" , " NotBlank" , "NotEmpty" };
10099
101100 /**
102101 * The constant POSITIVE_OR_ZERO.
103102 */
104- private static final String POSITIVE_OR_ZERO = "javax.validation.constraints. PositiveOrZero" ;
103+ private static final String POSITIVE_OR_ZERO = "PositiveOrZero" ;
105104
106105 /**
107106 * The constant NEGATIVE_OR_ZERO.
108107 */
109- private static final String NEGATIVE_OR_ZERO = "javax.validation.constraints. NegativeOrZero" ;
108+ private static final String NEGATIVE_OR_ZERO = "NegativeOrZero" ;
110109
111110 static {
112111 PARAM_TYPES_TO_IGNORE .add (WebRequest .class );
@@ -171,8 +170,7 @@ protected AbstractRequestService(GenericParameterService parameterBuilder, Reque
171170 this .parameterBuilder = parameterBuilder ;
172171 this .requestBodyService = requestBodyService ;
173172 this .operationService = operationService ;
174- if (parameterCustomizers .isPresent ())
175- parameterCustomizers .get ().removeIf (Objects ::isNull );
173+ parameterCustomizers .ifPresent (customizers -> customizers .removeIf (Objects ::isNull ));
176174 this .parameterCustomizers = parameterCustomizers ;
177175 this .localSpringDocParameterNameDiscoverer = localSpringDocParameterNameDiscoverer ;
178176 }
@@ -478,7 +476,7 @@ private Parameter buildParam(ParameterInfo parameterInfo, Components components,
478476 public void applyBeanValidatorAnnotations (final Parameter parameter , final List <Annotation > annotations ) {
479477 Map <String , Annotation > annos = new HashMap <>();
480478 if (annotations != null )
481- annotations .forEach (annotation -> annos .put (annotation .annotationType ().getName (), annotation ));
479+ annotations .forEach (annotation -> annos .put (annotation .annotationType ().getSimpleName (), annotation ));
482480 boolean annotationExists = Arrays .stream (ANNOTATIONS_FOR_REQUIRED ).anyMatch (annos ::containsKey );
483481 if (annotationExists )
484482 parameter .setRequired (true );
@@ -497,7 +495,7 @@ public void applyBeanValidatorAnnotations(final RequestBody requestBody, final L
497495 Map <String , Annotation > annos = new HashMap <>();
498496 boolean requestBodyRequired = false ;
499497 if (!CollectionUtils .isEmpty (annotations )) {
500- annotations .forEach (annotation -> annos .put (annotation .annotationType ().getName (), annotation ));
498+ annotations .forEach (annotation -> annos .put (annotation .annotationType ().getSimpleName (), annotation ));
501499 requestBodyRequired = annotations .stream ()
502500 .filter (annotation -> org .springframework .web .bind .annotation .RequestBody .class .equals (annotation .annotationType ()))
503501 .anyMatch (annotation -> ((org .springframework .web .bind .annotation .RequestBody ) annotation ).required ());
@@ -520,8 +518,8 @@ public void applyBeanValidatorAnnotations(final RequestBody requestBody, final L
520518 * @param schema the schema
521519 */
522520 private void calculateSize (Map <String , Annotation > annos , Schema <?> schema ) {
523- if (annos .containsKey (Size .class .getName ())) {
524- Size size = (Size ) annos .get (Size .class .getName ());
521+ if (annos .containsKey (Size .class .getSimpleName ())) {
522+ Size size = (Size ) annos .get (Size .class .getSimpleName ());
525523 if (OPENAPI_ARRAY_TYPE .equals (schema .getType ())) {
526524 schema .setMinItems (size .min ());
527525 schema .setMaxItems (size .max ());
@@ -588,35 +586,35 @@ private Map<String, io.swagger.v3.oas.annotations.Parameter> getApiParameters(Me
588586 * @param schema the schema
589587 */
590588 private void applyValidationsToSchema (Map <String , Annotation > annos , Schema <?> schema ) {
591- if (annos .containsKey (Min .class .getName ())) {
592- Min min = (Min ) annos .get (Min .class .getName ());
589+ if (annos .containsKey (Min .class .getSimpleName ())) {
590+ Min min = (Min ) annos .get (Min .class .getSimpleName ());
593591 schema .setMinimum (BigDecimal .valueOf (min .value ()));
594592 }
595- if (annos .containsKey (Max .class .getName ())) {
596- Max max = (Max ) annos .get (Max .class .getName ());
593+ if (annos .containsKey (Max .class .getSimpleName ())) {
594+ Max max = (Max ) annos .get (Max .class .getSimpleName ());
597595 schema .setMaximum (BigDecimal .valueOf (max .value ()));
598596 }
599597 calculateSize (annos , schema );
600- if (annos .containsKey (DecimalMin .class .getName ())) {
601- DecimalMin min = (DecimalMin ) annos .get (DecimalMin .class .getName ());
598+ if (annos .containsKey (DecimalMin .class .getSimpleName ())) {
599+ DecimalMin min = (DecimalMin ) annos .get (DecimalMin .class .getSimpleName ());
602600 if (min .inclusive ())
603601 schema .setMinimum (BigDecimal .valueOf (Double .parseDouble (min .value ())));
604602 else
605- schema .setExclusiveMinimum (! min . inclusive () );
603+ schema .setExclusiveMinimum (true );
606604 }
607- if (annos .containsKey (DecimalMax .class .getName ())) {
608- DecimalMax max = (DecimalMax ) annos .get (DecimalMax .class .getName ());
605+ if (annos .containsKey (DecimalMax .class .getSimpleName ())) {
606+ DecimalMax max = (DecimalMax ) annos .get (DecimalMax .class .getSimpleName ());
609607 if (max .inclusive ())
610608 schema .setMaximum (BigDecimal .valueOf (Double .parseDouble (max .value ())));
611609 else
612- schema .setExclusiveMaximum (! max . inclusive () );
610+ schema .setExclusiveMaximum (true );
613611 }
614612 if (annos .containsKey (POSITIVE_OR_ZERO ))
615613 schema .setMinimum (BigDecimal .ZERO );
616614 if (annos .containsKey (NEGATIVE_OR_ZERO ))
617615 schema .setMaximum (BigDecimal .ZERO );
618- if (annos .containsKey (Pattern .class .getName ())) {
619- Pattern pattern = (Pattern ) annos .get (Pattern .class .getName ());
616+ if (annos .containsKey (Pattern .class .getSimpleName ())) {
617+ Pattern pattern = (Pattern ) annos .get (Pattern .class .getSimpleName ());
620618 schema .setPattern (pattern .regexp ());
621619 }
622620 }
0 commit comments