@@ -1137,4 +1137,59 @@ public void nonReactiveWithFlow() throws Exception {
11371137 assertFileNotContains (Paths .get (output + "/src/main/kotlin/org/openapitools/api/TestV1ApiService.kt" ),
11381138 "Flow<kotlin.String>" );
11391139 }
1140+
1141+ @ Test
1142+ public void testValidationsInQueryParams_issue21238_Controller () throws IOException {
1143+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
1144+ KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen ();
1145+ codegen .setOutputDir (output .getAbsolutePath ());
1146+
1147+ List <File > files = new DefaultGenerator ()
1148+ .opts (
1149+ new ClientOptInput ()
1150+ .openAPI (TestUtils .parseSpec ("src/test/resources/3_0/kotlin/issue21238_queryParam_validation.yaml" ))
1151+ .config (codegen )
1152+ )
1153+ .generate ();
1154+
1155+ Assertions .assertThat (files ).contains (
1156+ new File (output , "src/main/kotlin/org/openapitools/api/PetApiController.kt" ),
1157+ new File (output , "src/main/kotlin/org/openapitools/api/UserApiController.kt" )
1158+ );
1159+
1160+ assertFileContains (Paths .get (output + "/src/main/kotlin/org/openapitools/api/PetApiController.kt" ),
1161+ "@NotNull" , "@Valid" );
1162+ assertFileContains (Paths .get (output + "/src/main/kotlin/org/openapitools/api/UserApiController.kt" ),
1163+ "@NotNull" , "@Valid" ,
1164+ "@Pattern(regexp=\" ^[a-zA-Z0-9]+[a-zA-Z0-9\\ \\ .\\ \\ -_]*[a-zA-Z0-9]+$\" )" ,
1165+ "@Parameter(description = \" The user name for login\" , required = true)" ,
1166+ "@Parameter(description = \" The password for login in clear text\" , required = true)" );
1167+ }
1168+
1169+ @ Test
1170+ public void testValidationsInQueryParams_issue21238_Api_Delegate () throws IOException {
1171+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
1172+ KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen ();
1173+ codegen .setOutputDir (output .getAbsolutePath ());
1174+ codegen .additionalProperties ().put (KotlinSpringServerCodegen .DELEGATE_PATTERN , true );
1175+
1176+ List <File > files = new DefaultGenerator ()
1177+ .opts (
1178+ new ClientOptInput ()
1179+ .openAPI (TestUtils .parseSpec ("src/test/resources/3_0/kotlin/issue21238_queryParam_validation.yaml" ))
1180+ .config (codegen )
1181+ )
1182+ .generate ();
1183+
1184+ Assertions .assertThat (files ).contains (
1185+ new File (output , "src/main/kotlin/org/openapitools/api/PetApi.kt" ),
1186+ new File (output , "src/main/kotlin/org/openapitools/api/UserApi.kt" )
1187+ );
1188+
1189+ assertFileContains (Paths .get (output + "/src/main/kotlin/org/openapitools/api/PetApi.kt" ),
1190+ "@NotNull" , "@Valid" );
1191+ assertFileContains (Paths .get (output + "/src/main/kotlin/org/openapitools/api/UserApi.kt" ),
1192+ "@NotNull" , "@Valid" , "@Pattern(regexp=\" ^[a-zA-Z0-9]+[a-zA-Z0-9\\ \\ .\\ \\ -_]*[a-zA-Z0-9]+$\" )" );
1193+ }
1194+
11401195}
0 commit comments