66import io .swagger .v3 .oas .models .info .Info ;
77import io .swagger .v3 .oas .models .servers .Server ;
88import io .swagger .v3 .parser .core .models .ParseOptions ;
9+ import java .util .HashMap ;
10+ import java .util .function .Consumer ;
11+ import java .util .stream .Stream ;
912import org .apache .commons .io .FileUtils ;
1013import org .assertj .core .api .Assertions ;
1114import org .jetbrains .annotations .NotNull ;
3134import java .nio .file .Path ;
3235import java .nio .file .Paths ;
3336import java .util .Collections ;
34- import java .util .HashMap ;
3537import java .util .List ;
3638import java .util .Map ;
37- import java .util .function .Consumer ;
3839import java .util .function .Function ;
3940import java .util .stream .Collectors ;
40- import java .util .stream .Stream ;
4141
4242import static org .assertj .core .api .Assertions .assertThat ;
4343import static org .openapitools .codegen .TestUtils .assertFileContains ;
@@ -372,6 +372,7 @@ public void delegateReactiveWithTags() throws Exception {
372372 "ApiUtil" );
373373 }
374374
375+
375376 @ Test
376377 public void testNullableMultipartFile () throws IOException {
377378 File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
@@ -439,6 +440,7 @@ public void arrayItemsCanBeNullable() throws IOException {
439440 assertFileContains (Paths .get (outputPath + "/src/main/kotlin/org/openapitools/model/ArrayWithNullableItemsModel.kt" ), "List<kotlin.String?>" );
440441 }
441442
443+
442444 @ Test
443445 public void doNotGenerateRequestParamForObjectQueryParam () throws IOException {
444446 File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
@@ -691,12 +693,12 @@ private static void testMultiLineOperationDescription(final boolean isInterfaceO
691693 Paths .get (
692694 outputPath + "/src/main/kotlin/org/openapitools/api/" + pingApiFileName ),
693695 "description = \" \" \" # Multi-line descriptions\n "
694- + "\n "
695- + "This is an example of a multi-line description.\n "
696- + "\n "
697- + "It:\n "
698- + "- has multiple lines\n "
699- + "- uses Markdown (CommonMark) for rich text representation\" \" \" "
696+ + "\n "
697+ + "This is an example of a multi-line description.\n "
698+ + "\n "
699+ + "It:\n "
700+ + "- has multiple lines\n "
701+ + "- uses Markdown (CommonMark) for rich text representation\" \" \" "
700702 );
701703 }
702704
@@ -815,10 +817,10 @@ public void contractWithEnumContainsEnumConverter() throws IOException {
815817 @ Test
816818 public void contractWithResolvedInnerEnumContainsEnumConverter () throws IOException {
817819 Map <String , File > files = generateFromContract (
818- "src/test/resources/3_0/inner_enum.yaml" ,
819- new HashMap <>(),
820- new HashMap <>(),
821- configurator -> configurator .addInlineSchemaOption ("RESOLVE_INLINE_ENUMS" , "true" )
820+ "src/test/resources/3_0/inner_enum.yaml" ,
821+ new HashMap <>(),
822+ new HashMap <>(),
823+ configurator -> configurator .addInlineSchemaOption ("RESOLVE_INLINE_ENUMS" , "true" )
822824 );
823825
824826 File enumConverterFile = files .get ("EnumConverterConfiguration.kt" );
@@ -862,6 +864,7 @@ public void givenMultipartFormArray_whenGenerateDelegateAndService_thenParameter
862864 Path controllerFile = Paths .get (outputPath + "/src/main/kotlin/org/openapitools/api/PetApi.kt" );
863865 assertFileContains (controllerFile , "images: Array<org.springframework.web.multipart.MultipartFile>" );
864866
867+
865868 Path serviceFile = Paths .get (outputPath + "/src/main/kotlin/org/openapitools/api/PetApiService.kt" );
866869 assertFileContains (serviceFile , "images: Array<org.springframework.web.multipart.MultipartFile>" );
867870 }
@@ -991,7 +994,6 @@ public void generateSerializableModel() throws Exception {
991994 "private const val serialVersionUID: kotlin.Long = 1"
992995 );
993996 }
994-
995997 @ Test
996998 public void generateSerializableModelWithXimplements () throws Exception {
997999 File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
@@ -1479,43 +1481,43 @@ public void testValidationsInQueryParams_issue21238_Api_Delegate() throws IOExce
14791481
14801482 @ DataProvider
14811483 public Object [][] issue17997DocumentationProviders () {
1482- return new Object [][] {
1483- { DocumentationProviderFeatures .DocumentationProvider .SPRINGDOC .name (),
1484- (Consumer <Path >) outputPath ->
1485- assertFileContains (
1486- outputPath ,
1487- "allowableValues = [\" 0\" , \" 1\" ], defaultValue = \" 0\" " ,
1488- "@PathVariable"
1489- ),
1490- (Consumer <Path >) outputPath ->
1491- assertFileContains (
1492- outputPath ,
1493- "allowableValues = [\" sleeping\" , \" awake\" ]" , "@PathVariable" ,
1494- "@PathVariable"
1495- )
1496- },
1497- { DocumentationProviderFeatures .DocumentationProvider .SPRINGFOX .name (),
1498- (Consumer <Path >) outputPath ->
1499- assertFileContains (
1500- outputPath ,
1501- "allowableValues = \" 0, 1\" , defaultValue = \" 0\" " ,
1502- "@PathVariable"
1503- ),
1504- (Consumer <Path >) outputPath ->
1505- assertFileContains (
1506- outputPath ,
1507- "allowableValues = \" sleeping, awake\" " , "@PathVariable" ,
1508- "@PathVariable"
1509- )
1510- }
1484+ return new Object [][]{
1485+ { DocumentationProviderFeatures .DocumentationProvider .SPRINGDOC .name (),
1486+ (Consumer <Path >) outputPath ->
1487+ assertFileContains (
1488+ outputPath ,
1489+ "allowableValues = [\" 0\" , \" 1\" ], defaultValue = \" 0\" " ,
1490+ "@PathVariable"
1491+ ),
1492+ (Consumer <Path >) outputPath ->
1493+ assertFileContains (
1494+ outputPath ,
1495+ "allowableValues = [\" sleeping\" , \" awake\" ]" , "@PathVariable" ,
1496+ "@PathVariable"
1497+ )
1498+ },
1499+ { DocumentationProviderFeatures .DocumentationProvider .SPRINGFOX .name (),
1500+ (Consumer <Path >) outputPath ->
1501+ assertFileContains (
1502+ outputPath ,
1503+ "allowableValues = \" 0, 1\" , defaultValue = \" 0\" " ,
1504+ "@PathVariable"
1505+ ),
1506+ (Consumer <Path >) outputPath ->
1507+ assertFileContains (
1508+ outputPath ,
1509+ "allowableValues = \" sleeping, awake\" " , "@PathVariable" ,
1510+ "@PathVariable"
1511+ )
1512+ }
15111513 };
15121514 }
15131515
15141516 @ Test (dataProvider = "issue17997DocumentationProviders" )
15151517 public void testDocumentationAnnotationInPathParams_Issue17997 (
1516- String documentProvider ,
1517- Consumer <Path > intEnumAssertFunction ,
1518- Consumer <Path > stringEnumAssertFunction
1518+ String documentProvider ,
1519+ Consumer <Path > intEnumAssertFunction ,
1520+ Consumer <Path > stringEnumAssertFunction
15191521 ) throws IOException {
15201522 Map <String , Object > additionalProperties = new HashMap <>();
15211523 additionalProperties .put (DOCUMENTATION_PROVIDER , documentProvider );
@@ -1526,23 +1528,23 @@ public void testDocumentationAnnotationInPathParams_Issue17997(
15261528 generatorPropertyDefaults .put (CodegenConstants .APIS , "true" );
15271529
15281530 Map <String , File > files = generateFromContract (
1529- "src/test/resources/3_0/issue_6762.yaml" ,
1530- additionalProperties ,
1531- generatorPropertyDefaults
1531+ "src/test/resources/3_0/issue_6762.yaml" ,
1532+ additionalProperties ,
1533+ generatorPropertyDefaults
15321534 );
15331535
15341536 Stream .of (
1535- "ZebrasApiController.kt" ,
1536- "GiraffesApiController.kt"
1537+ "ZebrasApiController.kt" ,
1538+ "GiraffesApiController.kt"
15371539 ).forEach (filename -> {
15381540 File file = files .get (filename );
15391541 assertThat (file ).isNotNull ();
15401542 intEnumAssertFunction .accept (file .toPath ());
15411543 });
15421544
15431545 Stream .of (
1544- "BearsApiController.kt" ,
1545- "CamelsApiController.kt"
1546+ "BearsApiController.kt" ,
1547+ "CamelsApiController.kt"
15461548 ).forEach (filename -> {
15471549 File file = files .get (filename );
15481550 assertThat (file ).isNotNull ();
@@ -1841,55 +1843,55 @@ public void testXMinimumMessageAndXMaximumMessage_long() throws IOException {
18411843 .assertParameter ("number" )
18421844 .assertParameterAnnotation ("Min" )
18431845 .hasAttributes (ImmutableMap .of (
1844- "value" , "1L" ,
1846+ "value" , "1L" ,
18451847 "message" , "\" Must be positive\" "
18461848 ))
18471849 .toParameter ()
18481850 .assertParameterAnnotation ("Max" )
18491851 .hasAttributes (ImmutableMap .of (
1850- "value" , "99L" ,
1852+ "value" , "99L" ,
18511853 "message" , "\" Must be less than 100\" "
18521854 ))
18531855 .toParameter ()
18541856 .toMethod ()
18551857 .assertParameter ("token" )
18561858 .assertParameterAnnotation ("Min" )
18571859 .hasAttributes (ImmutableMap .of (
1858- "value" , "1L" ,
1860+ "value" , "1L" ,
18591861 "message" , "\" Must be positive\" "
18601862 ))
18611863 .toParameter ()
18621864 .assertParameterAnnotation ("Max" )
18631865 .hasAttributes (ImmutableMap .of (
1864- "value" , "99L" ,
1866+ "value" , "99L" ,
18651867 "message" , "\" Must be less than 100\" "
18661868 ))
18671869 .toParameter ()
18681870 .toMethod ()
18691871 .assertParameter ("clientNumber" )
18701872 .assertParameterAnnotation ("Min" )
18711873 .hasAttributes (ImmutableMap .of (
1872- "value" , "1L" ,
1874+ "value" , "1L" ,
18731875 "message" , "\" Must be positive\" "
18741876 ))
18751877 .toParameter ()
18761878 .assertParameterAnnotation ("Max" )
18771879 .hasAttributes (ImmutableMap .of (
1878- "value" , "99L" ,
1880+ "value" , "99L" ,
18791881 "message" , "\" Must be less than 100\" "
18801882 ));
18811883 KotlinFileAssert .assertThat (files .get ("LongTest.kt" ))
18821884 .assertClass ("LongTest" )
18831885 .assertPrimaryConstructorParameter ("field1" )
18841886 .assertParameterAnnotation ("Min" , "get" )
18851887 .hasAttributes (ImmutableMap .of (
1886- "value" , "1L" ,
1888+ "value" , "1L" ,
18871889 "message" , "\" Must be positive\" "
18881890 ))
18891891 .toPrimaryConstructorParameter ()
18901892 .assertParameterAnnotation ("Max" , "get" )
18911893 .hasAttributes (ImmutableMap .of (
1892- "value" , "99L" ,
1894+ "value" , "99L" ,
18931895 "message" , "\" Must be less than 100\" "
18941896 ))
18951897 .toPrimaryConstructorParameter ()
@@ -1911,9 +1913,9 @@ private Map<String, File> generateFromContract(String url, Map<String, Object> a
19111913 }
19121914
19131915 private Map <String , File > generateFromContract (
1914- String url ,
1915- Map <String , Object > additionalProperties ,
1916- Map <String , String > generatorPropertyDefaults
1916+ String url ,
1917+ Map <String , Object > additionalProperties ,
1918+ Map <String , String > generatorPropertyDefaults
19171919 ) throws IOException {
19181920 return generateFromContract (url , additionalProperties , generatorPropertyDefaults , codegen -> {
19191921 });
@@ -1925,22 +1927,22 @@ private Map<String, File> generateFromContract(
19251927 * use CodegenConfigurator instead of CodegenConfig for easier configuration like in JavaClientCodeGenTest
19261928 */
19271929 private Map <String , File > generateFromContract (
1928- String url ,
1929- Map <String , Object > additionalProperties ,
1930- Map <String , String > generatorPropertyDefaults ,
1931- Consumer <CodegenConfigurator > consumer
1930+ String url ,
1931+ Map <String , Object > additionalProperties ,
1932+ Map <String , String > generatorPropertyDefaults ,
1933+ Consumer <CodegenConfigurator > consumer
19321934 ) throws IOException {
19331935
19341936 File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
19351937 output .deleteOnExit ();
19361938
19371939 final CodegenConfigurator configurator = new CodegenConfigurator ()
1938- .setGeneratorName ("kotlin-spring" )
1939- .setAdditionalProperties (additionalProperties )
1940- .setValidateSpec (false )
1941- .setInputSpec (url )
1942- .setLibrary (SPRING_BOOT )
1943- .setOutputDir (output .getAbsolutePath ());
1940+ .setGeneratorName ("kotlin-spring" )
1941+ .setAdditionalProperties (additionalProperties )
1942+ .setValidateSpec (false )
1943+ .setInputSpec (url )
1944+ .setLibrary (SPRING_BOOT )
1945+ .setOutputDir (output .getAbsolutePath ());
19441946
19451947 consumer .accept (configurator );
19461948
@@ -1950,6 +1952,6 @@ private Map<String, File> generateFromContract(
19501952 generatorPropertyDefaults .forEach (generator ::setGeneratorPropertyDefault );
19511953
19521954 return generator .opts (input ).generate ().stream ()
1953- .collect (Collectors .toMap (File ::getName , Function .identity ()));
1955+ .collect (Collectors .toMap (File ::getName , Function .identity ()));
19541956 }
19551957}
0 commit comments