Skip to content

Commit dfd05de

Browse files
committed
test (JAVA CLIENTS): add another test for the useOneOfInterfaces option
1 parent c21158d commit dfd05de

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,4 +3672,38 @@ public void testClientWithUseOneOfInterface_issue_17419(String client) {
36723672

36733673
}
36743674

3675+
@Test(dataProvider = "allJavaClients")
3676+
public void testClientWithUseOneOfInterfaceWithoutDiscriminator_issue_17419(String client) {
3677+
// given
3678+
final Path output = newTempFolder();
3679+
final CodegenConfigurator configurator = new CodegenConfigurator()
3680+
.setGeneratorName("java")
3681+
.setLibrary(client)
3682+
.setAdditionalProperties(Map.of("useOneOfInterfaces", "true"))
3683+
.setInputSpec("src/test/resources/3_0/typescript-fetch/oneOf.yaml")
3684+
.setOutputDir(output.toString().replace("\\", "/"));
3685+
3686+
final ClientOptInput input = configurator.toClientOptInput();
3687+
3688+
// when
3689+
List<File> files = new DefaultGenerator().opts(input).generate();
3690+
3691+
// then
3692+
validateJavaSourceFiles(files);
3693+
3694+
TestUtils.assertFileContains(
3695+
output.resolve("src/main/java/org/openapitools/client/model/TestResponse.java"),
3696+
"public interface TestResponse {"
3697+
);
3698+
TestUtils.assertFileContains(
3699+
output.resolve("src/main/java/org/openapitools/client/model/TestA.java"),
3700+
"implements TestResponse"
3701+
);
3702+
TestUtils.assertFileContains(
3703+
output.resolve("src/main/java/org/openapitools/client/model/TestB.java"),
3704+
"implements TestResponse"
3705+
);
3706+
3707+
}
3708+
36753709
}

0 commit comments

Comments
 (0)