@@ -2743,6 +2743,42 @@ public void useBeanValidationGenerateAnnotationsForRequestBody_issue13932() thro
27432743 .containsWithNameAndAttributes ("Min" , ImmutableMap .of ("value" , "2" ));
27442744 }
27452745
2746+ @ Test
2747+ public void useBeanValidationGenerateAnnotationsForFormsRequestBody () throws IOException {
2748+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
2749+ output .deleteOnExit ();
2750+
2751+ OpenAPI openAPI = new OpenAPIParser ()
2752+ .readLocation ("src/test/resources/3_0/spring/form-requestbody-params-with-constraints.yaml" , null , new ParseOptions ()).getOpenAPI ();
2753+ SpringCodegen codegen = new SpringCodegen ();
2754+ codegen .setLibrary (SPRING_BOOT );
2755+ codegen .setOutputDir (output .getAbsolutePath ());
2756+ codegen .additionalProperties ().put (SpringCodegen .INTERFACE_ONLY , "true" );
2757+ codegen .additionalProperties ().put (SpringCodegen .USE_BEANVALIDATION , "true" );
2758+ codegen .additionalProperties ().put (CodegenConstants .MODEL_PACKAGE , "xyz.model" );
2759+ codegen .additionalProperties ().put (CodegenConstants .API_PACKAGE , "xyz.controller" );
2760+
2761+ ClientOptInput input = new ClientOptInput ()
2762+ .openAPI (openAPI )
2763+ .config (codegen );
2764+
2765+ DefaultGenerator generator = new DefaultGenerator ();
2766+ generator .setGenerateMetadata (false );
2767+ Map <String , File > files = generator .opts (input ).generate ().stream ()
2768+ .collect (Collectors .toMap (File ::getName , Function .identity ()));
2769+
2770+ JavaFileAssert .assertThat (files .get ("AddApi.java" ))
2771+ .assertMethod ("addPost" )
2772+ .assertParameter ("name" )
2773+ .assertParameterAnnotations ()
2774+ .containsWithNameAndAttributes ("Pattern" , ImmutableMap .of ("regexp" , "\" ^[[:print:]]+$\" " ))
2775+ .toParameter ()
2776+ .toMethod ()
2777+ .assertParameter ("quantity" )
2778+ .assertParameterAnnotations ()
2779+ .containsWithNameAndAttributes ("Min" , ImmutableMap .of ("value" , "1" ));
2780+ }
2781+
27462782 @ Test
27472783 public void shouldHandleSeparatelyInterfaceAndModelAdditionalAnnotations () throws IOException {
27482784 File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
0 commit comments