|
43 | 43 | import java.util.Map; |
44 | 44 |
|
45 | 45 | import static org.openapitools.codegen.CodegenConstants.*; |
| 46 | +import static org.openapitools.codegen.TestUtils.assertFileContains; |
46 | 47 |
|
47 | 48 | @SuppressWarnings("static-method") |
48 | 49 | public class KotlinClientCodegenModelTest { |
@@ -617,6 +618,32 @@ public void polymorphicJacksonSerialization() throws IOException { |
617 | 618 | TestUtils.assertFileNotContains(birdKt, "val discriminator"); |
618 | 619 | } |
619 | 620 |
|
| 621 | + @Test |
| 622 | + public void testIntArrayToEnum() throws IOException { |
| 623 | + File output = Files.createTempDirectory("test").toFile(); |
| 624 | + output.deleteOnExit(); |
| 625 | + |
| 626 | + final CodegenConfigurator configurator = new CodegenConfigurator() |
| 627 | + .setGeneratorName("kotlin") |
| 628 | + .setLibrary("jvm-ktor") |
| 629 | + .setAdditionalProperties(new HashMap<>() {{ |
| 630 | + put(CodegenConstants.SERIALIZATION_LIBRARY, "jackson"); |
| 631 | + put(CodegenConstants.MODEL_PACKAGE, "model"); |
| 632 | + put(ENUM_PROPERTY_NAMING, "UPPERCASE"); |
| 633 | + }}) |
| 634 | + .setInputSpec("src/test/resources/3_0/kotlin/issue15204-int-array-enum.yaml") |
| 635 | + .setOutputDir(output.getAbsolutePath().replace("\\", "/")); |
| 636 | + |
| 637 | + final ClientOptInput clientOptInput = configurator.toClientOptInput(); |
| 638 | + DefaultGenerator generator = new DefaultGenerator(); |
| 639 | + |
| 640 | + generator.opts(clientOptInput).generate(); |
| 641 | + |
| 642 | + final Path modelKt = Paths.get(output + "/src/main/kotlin/model/ModelWithIntArrayEnum.kt"); |
| 643 | + |
| 644 | + TestUtils.assertFileContains(modelKt, "enum class DaysOfWeek(val value: kotlin.Int)"); |
| 645 | + } |
| 646 | + |
620 | 647 | private static class ModelNameTest { |
621 | 648 | private final String expectedName; |
622 | 649 | private final String expectedClassName; |
|
0 commit comments