|
28 | 28 | import org.openapitools.codegen.*;
|
29 | 29 | import org.openapitools.codegen.languages.PythonClientCodegen;
|
30 | 30 | import org.openapitools.codegen.languages.features.CXFServerFeatures;
|
| 31 | + |
| 32 | +import static org.junit.jupiter.api.Assertions.assertNull; |
31 | 33 | import static org.openapitools.codegen.TestUtils.assertFileContains;
|
32 | 34 | import static org.openapitools.codegen.TestUtils.assertFileExists;
|
33 | 35 | import org.openapitools.codegen.TestUtils;
|
@@ -541,4 +543,27 @@ public void testEnumPropertyWithQuotes() {
|
541 | 543 | Assert.assertEquals(codegen.toEnumValue("1.0", "float"), "1.0");
|
542 | 544 | Assert.assertEquals(codegen.toEnumValue("1", "int"), "1");
|
543 | 545 | }
|
| 546 | + |
| 547 | + @Test |
| 548 | + public void testHandleNoApis() throws IOException { |
| 549 | + File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); |
| 550 | + output.deleteOnExit(); |
| 551 | + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/no_apis.yaml"); |
| 552 | + final DefaultGenerator defaultGenerator = new DefaultGenerator(); |
| 553 | + final ClientOptInput clientOptInput = new ClientOptInput(); |
| 554 | + clientOptInput.openAPI(openAPI); |
| 555 | + PythonClientCodegen pythonClientCodegen = new PythonClientCodegen(); |
| 556 | + pythonClientCodegen.setOutputDir(output.getAbsolutePath()); |
| 557 | + clientOptInput.config(pythonClientCodegen); |
| 558 | + defaultGenerator.opts(clientOptInput); |
| 559 | + |
| 560 | + Map<String, File> files = defaultGenerator.generate().stream().collect(Collectors.toMap(File::getPath, Function.identity())); |
| 561 | + |
| 562 | + File apiFile = files.get(Paths.get(output.getAbsolutePath(), "openapi_client", "api", "hello_example_api.py").toString()); |
| 563 | + assertNull(apiFile); |
| 564 | + |
| 565 | + File setupFile = files.get(Paths.get(output.getAbsolutePath(), "setup.py").toString()); |
| 566 | + assertNotNull(setupFile); |
| 567 | + assertFileContains(setupFile.toPath(), "setup("); |
| 568 | + } |
544 | 569 | }
|
0 commit comments