forked from loafle/openapi-generator-original
Add tests for duplicated operationId (#20070)
* add tests for duplicated operation id * add spec file
This commit is contained in:
parent
b34df341a4
commit
1bda458882
@ -69,7 +69,8 @@ import static org.testng.Assert.*;
|
|||||||
public class JavaClientCodegenTest {
|
public class JavaClientCodegenTest {
|
||||||
|
|
||||||
// This is the kind of information that ideally would be defined and available system-wide
|
// This is the kind of information that ideally would be defined and available system-wide
|
||||||
@Getter enum Library {
|
@Getter
|
||||||
|
enum Library {
|
||||||
APACHE_HTTPCLIENT("apache-httpclient", Serializer.JACKSON),
|
APACHE_HTTPCLIENT("apache-httpclient", Serializer.JACKSON),
|
||||||
FEIGN("feign", Serializer.JACKSON, Set.of(Serializer.GSON)),
|
FEIGN("feign", Serializer.JACKSON, Set.of(Serializer.GSON)),
|
||||||
GOOGLE_API_CLIENT("google-api-client", Serializer.JACKSON),
|
GOOGLE_API_CLIENT("google-api-client", Serializer.JACKSON),
|
||||||
@ -105,35 +106,41 @@ public class JavaClientCodegenTest {
|
|||||||
|
|
||||||
enum Serializer {
|
enum Serializer {
|
||||||
GSON, JACKSON, JSONB;
|
GSON, JACKSON, JSONB;
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.name().toLowerCase(Locale.ROOT);
|
return this.name().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataProvider Iterator<Library> supportedLibraries() {
|
@DataProvider
|
||||||
|
Iterator<Library> supportedLibraries() {
|
||||||
return Arrays.stream(Library.values()).iterator();
|
return Arrays.stream(Library.values()).iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataProvider Iterator<Library> librariesSupportingGson() {
|
@DataProvider
|
||||||
|
Iterator<Library> librariesSupportingGson() {
|
||||||
return Arrays.stream(Library.values())
|
return Arrays.stream(Library.values())
|
||||||
.filter(library -> library.getSupportedSerializers().contains(Serializer.GSON))
|
.filter(library -> library.getSupportedSerializers().contains(Serializer.GSON))
|
||||||
.iterator();
|
.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataProvider Iterator<Library> librariesSupportingJackson() {
|
@DataProvider
|
||||||
|
Iterator<Library> librariesSupportingJackson() {
|
||||||
return Arrays.stream(Library.values())
|
return Arrays.stream(Library.values())
|
||||||
.filter(library -> library.getSupportedSerializers().contains(Serializer.JACKSON))
|
.filter(library -> library.getSupportedSerializers().contains(Serializer.JACKSON))
|
||||||
.iterator();
|
.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataProvider Iterator<Library> librariesNotSupportingJackson() {
|
@DataProvider
|
||||||
|
Iterator<Library> librariesNotSupportingJackson() {
|
||||||
return Arrays.stream(Library.values())
|
return Arrays.stream(Library.values())
|
||||||
.filter(library -> !library.getSupportedSerializers().contains(Serializer.JACKSON))
|
.filter(library -> !library.getSupportedSerializers().contains(Serializer.JACKSON))
|
||||||
.iterator();
|
.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test public void arraysInRequestBody() {
|
@Test
|
||||||
|
public void arraysInRequestBody() {
|
||||||
OpenAPI openAPI = TestUtils.createOpenAPI();
|
OpenAPI openAPI = TestUtils.createOpenAPI();
|
||||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
@ -282,7 +289,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_JACKSON);
|
Assertions.assertEquals(codegen.getSerializationLibrary(), JavaClientCodegen.SERIALIZATION_LIBRARY_JACKSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testGeneratedAuthClassesJersey() {
|
@Test
|
||||||
|
public void testGeneratedAuthClassesJersey() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -302,7 +310,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testImportMappingResult() {
|
@Test
|
||||||
|
public void testImportMappingResult() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.addTypeMapping("OffsetDateTime", "Instant")
|
.addTypeMapping("OffsetDateTime", "Instant")
|
||||||
@ -326,7 +335,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertTrue(codegen.getFeatureSet().getSecurityFeatures().contains(SecurityFeature.SignatureAuth));
|
Assertions.assertTrue(codegen.getFeatureSet().getSecurityFeatures().contains(SecurityFeature.SignatureAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testPackageNamesSetInvokerDerivedFromApi() {
|
@Test
|
||||||
|
public void testPackageNamesSetInvokerDerivedFromApi() {
|
||||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||||
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.yyyyy.zzzzzzz.aaaaa.api");
|
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "xyz.yyyyy.zzzzzzz.aaaaa.api");
|
||||||
@ -339,7 +349,8 @@ public class JavaClientCodegenTest {
|
|||||||
configAssert.assertValue(CodegenConstants.INVOKER_PACKAGE, codegen::getInvokerPackage, "xyz.yyyyy.zzzzzzz.aaaaa");
|
configAssert.assertValue(CodegenConstants.INVOKER_PACKAGE, codegen::getInvokerPackage, "xyz.yyyyy.zzzzzzz.aaaaa");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testPackageNamesSetInvokerDerivedFromModel() {
|
@Test
|
||||||
|
public void testPackageNamesSetInvokerDerivedFromModel() {
|
||||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
codegen.additionalProperties().put(CodegenConstants.MODEL_PACKAGE, "xyz.yyyyy.zzzzzzz.mmmmm.model");
|
||||||
|
|
||||||
@ -351,7 +362,8 @@ public class JavaClientCodegenTest {
|
|||||||
configAssert.assertValue(CodegenConstants.INVOKER_PACKAGE, codegen::getInvokerPackage, "xyz.yyyyy.zzzzzzz.mmmmm");
|
configAssert.assertValue(CodegenConstants.INVOKER_PACKAGE, codegen::getInvokerPackage, "xyz.yyyyy.zzzzzzz.mmmmm");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testGetSchemaTypeWithComposedSchemaWithAllOf() {
|
@Test
|
||||||
|
public void testGetSchemaTypeWithComposedSchemaWithAllOf() {
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/composed-allof.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/composed-allof.yaml");
|
||||||
Operation operation = openAPI.getPaths().get("/ping").getPost();
|
Operation operation = openAPI.getPaths().get("/ping").getPost();
|
||||||
|
|
||||||
@ -361,7 +373,8 @@ public class JavaClientCodegenTest {
|
|||||||
.first().hasFieldOrPropertyWithValue("baseType", "MessageEventCoreWithTimeListEntries");
|
.first().hasFieldOrPropertyWithValue("baseType", "MessageEventCoreWithTimeListEntries");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void updateCodegenPropertyEnum() {
|
@Test
|
||||||
|
public void updateCodegenPropertyEnum() {
|
||||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
CodegenProperty array = codegenPropertyWithArrayOfIntegerValues();
|
CodegenProperty array = codegenPropertyWithArrayOfIntegerValues();
|
||||||
|
|
||||||
@ -375,7 +388,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
Assertions.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void updateCodegenPropertyEnumWithCustomNames() {
|
@Test
|
||||||
|
public void updateCodegenPropertyEnumWithCustomNames() {
|
||||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
CodegenProperty array = codegenPropertyWithArrayOfIntegerValues();
|
CodegenProperty array = codegenPropertyWithArrayOfIntegerValues();
|
||||||
array.getItems().setVendorExtensions(Map.of("x-enum-varnames", Collections.singletonList("ONE")));
|
array.getItems().setVendorExtensions(Map.of("x-enum-varnames", Collections.singletonList("ONE")));
|
||||||
@ -390,7 +404,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
Assertions.assertEquals(testedEnumVar.getOrDefault("value", ""), "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testGeneratePing() {
|
@Test
|
||||||
|
public void testGeneratePing() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -446,7 +461,8 @@ public class JavaClientCodegenTest {
|
|||||||
.contains("public class DefaultApi");
|
.contains("public class DefaultApi");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testGeneratePingSomeObj(){
|
@Test
|
||||||
|
public void testGeneratePingSomeObj() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -508,7 +524,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testJdkHttpClient() {
|
@Test
|
||||||
|
public void testJdkHttpClient() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -534,7 +551,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testJdkHttpClientWithUseBeanValidationEnabled() {
|
@Test
|
||||||
|
public void testJdkHttpClientWithUseBeanValidationEnabled() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -552,7 +570,8 @@ public class JavaClientCodegenTest {
|
|||||||
.contains("@Pattern", "import jakarta.validation.constraints.*");
|
.contains("@Pattern", "import jakarta.validation.constraints.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testJdkHttpClientWithAndWithoutDiscriminator() {
|
@Test
|
||||||
|
public void testJdkHttpClientWithAndWithoutDiscriminator() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -574,7 +593,8 @@ public class JavaClientCodegenTest {
|
|||||||
.contains("import xyz.abcdef.invoker.JSON;");
|
.contains("import xyz.abcdef.invoker.JSON;");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testJdkHttpAsyncClient() {
|
@Test
|
||||||
|
public void testJdkHttpAsyncClient() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -655,7 +675,8 @@ public class JavaClientCodegenTest {
|
|||||||
assertEquals(postScopes.size(), 2, "POST scopes don't match. actual:" + postScopes);
|
assertEquals(postScopes.size(), 2, "POST scopes don't match. actual:" + postScopes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testAuthorizationScopeValues_Issue6733() {
|
@Test
|
||||||
|
public void testAuthorizationScopeValues_Issue6733() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -678,7 +699,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertEquals(files.size(), 1);
|
Assertions.assertEquals(files.size(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testTypedAndNonTypedComposedSchemaGeneration_3_1() {
|
@Test
|
||||||
|
public void testTypedAndNonTypedComposedSchemaGeneration_3_1() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -700,7 +722,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertEquals(files.size(), 9);
|
Assertions.assertEquals(files.size(), 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testMultiPartSpecifiesFileName_Issue17367() throws IOException {
|
@Test
|
||||||
|
public void testMultiPartSpecifiesFileName_Issue17367() throws IOException {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -732,7 +755,8 @@ public class JavaClientCodegenTest {
|
|||||||
"file.getName\\(\\)\\);.*")));
|
"file.getName\\(\\)\\);.*")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testAuthorizationsMethodsSizeWhenFiltered() {
|
@Test
|
||||||
|
public void testAuthorizationsMethodsSizeWhenFiltered() {
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue4584.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue4584.yaml");
|
||||||
final ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(new JavaClientCodegen());
|
final ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(new JavaClientCodegen());
|
||||||
final DefaultGenerator defaultGenerator = new DefaultGenerator();
|
final DefaultGenerator defaultGenerator = new DefaultGenerator();
|
||||||
@ -748,7 +772,8 @@ public class JavaClientCodegenTest {
|
|||||||
assertEquals(getCodegenOperation.authMethods.size(), 2);
|
assertEquals(getCodegenOperation.authMethods.size(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testFreeFormObjects() {
|
@Test
|
||||||
|
public void testFreeFormObjects() {
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue796.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue796.yaml");
|
||||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
|
|
||||||
@ -783,7 +808,8 @@ public class JavaClientCodegenTest {
|
|||||||
/**
|
/**
|
||||||
* See https://github.com/OpenAPITools/openapi-generator/issues/3589
|
* See https://github.com/OpenAPITools/openapi-generator/issues/3589
|
||||||
*/
|
*/
|
||||||
@Test public void testSchemaMapping() throws IOException {
|
@Test
|
||||||
|
public void testSchemaMapping() throws IOException {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final ClientOptInput clientOptInput = new CodegenConfigurator()
|
final ClientOptInput clientOptInput = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -819,7 +845,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertEquals(fieldMatcher.group(1), "foo.bar.TypeAlias");
|
Assertions.assertEquals(fieldMatcher.group(1), "foo.bar.TypeAlias");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testBearerAuth() {
|
@Test
|
||||||
|
public void testBearerAuth() {
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/pingBearerAuth.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/pingBearerAuth.yaml");
|
||||||
|
|
||||||
List<CodegenSecurity> security = new JavaClientCodegen().fromSecurity(openAPI.getComponents().getSecuritySchemes());
|
List<CodegenSecurity> security = new JavaClientCodegen().fromSecurity(openAPI.getComponents().getSecuritySchemes());
|
||||||
@ -831,7 +858,8 @@ public class JavaClientCodegenTest {
|
|||||||
.hasFieldOrPropertyWithValue("isBasicBearer", Boolean.TRUE);
|
.hasFieldOrPropertyWithValue("isBasicBearer", Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testVertXAuthInfoWithHyphenSeparatedSecurityScheme() {
|
@Test
|
||||||
|
public void testVertXAuthInfoWithHyphenSeparatedSecurityScheme() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1042,7 +1070,8 @@ public class JavaClientCodegenTest {
|
|||||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||||
* how we can fix it accordingly.
|
* how we can fix it accordingly.
|
||||||
*/
|
*/
|
||||||
@Test(enabled = false) public void testRestTemplateFormMultipart() {
|
@Test(enabled = false)
|
||||||
|
public void testRestTemplateFormMultipart() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1077,7 +1106,8 @@ public class JavaClientCodegenTest {
|
|||||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||||
* how we can fix it accordingly.
|
* how we can fix it accordingly.
|
||||||
*/
|
*/
|
||||||
@Test(enabled = false) public void testWebClientFormMultipart() {
|
@Test(enabled = false)
|
||||||
|
public void testWebClientFormMultipart() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1136,7 +1166,8 @@ public class JavaClientCodegenTest {
|
|||||||
"List<Pet>"); // explicit 'x-webclient-blocking: true' which overrides global config
|
"List<Pet>"); // explicit 'x-webclient-blocking: true' which overrides global config
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testAllowModelWithNoProperties() {
|
@Test
|
||||||
|
public void testAllowModelWithNoProperties() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1164,7 +1195,8 @@ public class JavaClientCodegenTest {
|
|||||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||||
* how we can fix it accordingly.
|
* how we can fix it accordingly.
|
||||||
*/
|
*/
|
||||||
@Test(enabled = false) public void testRestTemplateWithUseAbstractionForFiles() {
|
@Test(enabled = false)
|
||||||
|
public void testRestTemplateWithUseAbstractionForFiles() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1197,7 +1229,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test void testNotDuplicateOauth2FlowsScopes() {
|
@Test
|
||||||
|
void testNotDuplicateOauth2FlowsScopes() {
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_7614.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_7614.yaml");
|
||||||
final ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(new JavaClientCodegen());
|
final ClientOptInput clientOptInput = new ClientOptInput().openAPI(openAPI).config(new JavaClientCodegen());
|
||||||
final DefaultGenerator defaultGenerator = new DefaultGenerator();
|
final DefaultGenerator defaultGenerator = new DefaultGenerator();
|
||||||
@ -1249,7 +1282,8 @@ public class JavaClientCodegenTest {
|
|||||||
.findFirst();
|
.findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testCustomMethodParamsAreCamelizedWhenUsingFeign() {
|
@Test
|
||||||
|
public void testCustomMethodParamsAreCamelizedWhenUsingFeign() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1276,7 +1310,8 @@ public class JavaClientCodegenTest {
|
|||||||
/**
|
/**
|
||||||
* see https://github.com/OpenAPITools/openapi-generator/issues/19895
|
* see https://github.com/OpenAPITools/openapi-generator/issues/19895
|
||||||
*/
|
*/
|
||||||
@Test public void testCharsetInContentTypeCorrectlyEncodedForFeignApi_issue19895() {
|
@Test
|
||||||
|
public void testCharsetInContentTypeCorrectlyEncodedForFeignApi_issue19895() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1308,7 +1343,8 @@ public class JavaClientCodegenTest {
|
|||||||
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
* We will contact the contributor of the following test to see if the fix will break their use cases and
|
||||||
* how we can fix it accordingly.
|
* how we can fix it accordingly.
|
||||||
*/
|
*/
|
||||||
@Test(enabled = false) public void testWebClientWithUseAbstractionForFiles() {
|
@Test(enabled = false)
|
||||||
|
public void testWebClientWithUseAbstractionForFiles() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1359,7 +1395,8 @@ public class JavaClientCodegenTest {
|
|||||||
/**
|
/**
|
||||||
* See https://github.com/OpenAPITools/openapi-generator/issues/8352
|
* See https://github.com/OpenAPITools/openapi-generator/issues/8352
|
||||||
*/
|
*/
|
||||||
@Test public void testWebClientWithFreeFormInQueryParameters() {
|
@Test
|
||||||
|
public void testWebClientWithFreeFormInQueryParameters() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
|
final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
|
||||||
.setLibrary(JavaClientCodegen.WEBCLIENT)
|
.setLibrary(JavaClientCodegen.WEBCLIENT)
|
||||||
@ -1377,7 +1414,8 @@ public class JavaClientCodegenTest {
|
|||||||
/**
|
/**
|
||||||
* See https://github.com/OpenAPITools/openapi-generator/issues/11242
|
* See https://github.com/OpenAPITools/openapi-generator/issues/11242
|
||||||
*/
|
*/
|
||||||
@Test public void testNativeClientWhiteSpacePathParamEncoding() {
|
@Test
|
||||||
|
public void testNativeClientWhiteSpacePathParamEncoding() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1399,7 +1437,8 @@ public class JavaClientCodegenTest {
|
|||||||
/**
|
/**
|
||||||
* See https://github.com/OpenAPITools/openapi-generator/issues/4808
|
* See https://github.com/OpenAPITools/openapi-generator/issues/4808
|
||||||
*/
|
*/
|
||||||
@Test public void testNativeClientExplodedQueryParamObject() {
|
@Test
|
||||||
|
public void testNativeClientExplodedQueryParamObject() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1421,7 +1460,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testDefaultMicroprofileRestClientVersion() {
|
@Test
|
||||||
|
public void testDefaultMicroprofileRestClientVersion() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1443,7 +1483,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testMicroprofileRestClientVersion_1_4_1() {
|
@Test
|
||||||
|
public void testMicroprofileRestClientVersion_1_4_1() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "1.4.1"))
|
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "1.4.1"))
|
||||||
@ -1486,7 +1527,8 @@ public class JavaClientCodegenTest {
|
|||||||
fail("Expected an exception that did not occur");
|
fail("Expected an exception that did not occur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testMicroprofileRestClientVersion_3_0() {
|
@Test
|
||||||
|
public void testMicroprofileRestClientVersion_3_0() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0"))
|
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0"))
|
||||||
@ -1509,7 +1551,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testMicroprofileGenerateCorrectJsonbCreator_issue12622() {
|
@Test
|
||||||
|
public void testMicroprofileGenerateCorrectJsonbCreator_issue12622() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0"))
|
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0"))
|
||||||
@ -1566,7 +1609,8 @@ public class JavaClientCodegenTest {
|
|||||||
.containsWithNameAndAttributes("JsonProperty", ImmutableMap.of("value", "JSON_PROPERTY_NAME", "required", "true"));
|
.containsWithNameAndAttributes("JsonProperty", ImmutableMap.of("value", "JSON_PROPERTY_NAME", "required", "true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testJavaClientDefaultValues_issueNoNumber() {
|
@Test
|
||||||
|
public void testJavaClientDefaultValues_issueNoNumber() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0"))
|
.setAdditionalProperties(Map.of(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0"))
|
||||||
@ -1589,7 +1633,8 @@ public class JavaClientCodegenTest {
|
|||||||
.asString().endsWith("= new ArrayList<>();");
|
.asString().endsWith("= new ArrayList<>();");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testWebClientJsonCreatorWithNullable_issue12790() {
|
@Test
|
||||||
|
public void testWebClientJsonCreatorWithNullable_issue12790() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setAdditionalProperties(Map.of(AbstractJavaCodegen.OPENAPI_NULLABLE, "true"))
|
.setAdditionalProperties(Map.of(AbstractJavaCodegen.OPENAPI_NULLABLE, "true"))
|
||||||
@ -1610,7 +1655,8 @@ public class JavaClientCodegenTest {
|
|||||||
"this.notNullableProperty = notNullableProperty;");
|
"this.notNullableProperty = notNullableProperty;");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestTemplateResponseTypeWithUseAbstractionForFiles() {
|
@Test
|
||||||
|
public void testRestTemplateResponseTypeWithUseAbstractionForFiles() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1632,7 +1678,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dataProvider = "supportedLibraries") void testExtraAnnotations(Library library) {
|
@Test(dataProvider = "supportedLibraries")
|
||||||
|
void testExtraAnnotations(Library library) {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final String outputPath = output.toString().replace('\\', '/');
|
final String outputPath = output.toString().replace('\\', '/');
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
@ -1654,7 +1701,8 @@ public class JavaClientCodegenTest {
|
|||||||
/**
|
/**
|
||||||
* See https://github.com/OpenAPITools/openapi-generator/issues/11340
|
* See https://github.com/OpenAPITools/openapi-generator/issues/11340
|
||||||
*/
|
*/
|
||||||
@Test public void testReferencedHeader2() {
|
@Test
|
||||||
|
public void testReferencedHeader2() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
|
final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
|
||||||
.setAdditionalProperties(Map.of(BeanValidationFeatures.USE_BEANVALIDATION, "true"))
|
.setAdditionalProperties(Map.of(BeanValidationFeatures.USE_BEANVALIDATION, "true"))
|
||||||
@ -1675,7 +1723,8 @@ public class JavaClientCodegenTest {
|
|||||||
.containsWithName("NotNull");
|
.containsWithName("NotNull");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testReturnTypeMapping() {
|
@Test
|
||||||
|
public void testReturnTypeMapping() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1708,7 +1757,8 @@ public class JavaClientCodegenTest {
|
|||||||
+ " queryObject.getValues()));");
|
+ " queryObject.getValues()));");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testJdkHttpClientWithAndWithoutParentExtension() {
|
@Test
|
||||||
|
public void testJdkHttpClientWithAndWithoutParentExtension() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -1735,7 +1785,8 @@ public class JavaClientCodegenTest {
|
|||||||
.content().contains("public class AnotherChild {");
|
.content().contains("public class AnotherChild {");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testDiscriminatorWithMappingIssue14731() {
|
@Test
|
||||||
|
public void testDiscriminatorWithMappingIssue14731() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final OpenAPI openAPI = new OpenAPIParser()
|
final OpenAPI openAPI = new OpenAPIParser()
|
||||||
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions())
|
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions())
|
||||||
@ -1767,7 +1818,8 @@ public class JavaClientCodegenTest {
|
|||||||
.content().doesNotContain("@JsonTypeName");
|
.content().doesNotContain("@JsonTypeName");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testDiscriminatorWithoutMappingIssue14731() {
|
@Test
|
||||||
|
public void testDiscriminatorWithoutMappingIssue14731() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final OpenAPI openAPI = new OpenAPIParser()
|
final OpenAPI openAPI = new OpenAPIParser()
|
||||||
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions())
|
.readLocation("src/test/resources/bugs/issue_14731.yaml", null, new ParseOptions())
|
||||||
@ -1799,7 +1851,8 @@ public class JavaClientCodegenTest {
|
|||||||
.content().contains("@JsonTypeName");
|
.content().contains("@JsonTypeName");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testForJavaNativeJsonSubtype() {
|
@Test
|
||||||
|
public void testForJavaNativeJsonSubtype() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final OpenAPI openAPI = new OpenAPIParser()
|
final OpenAPI openAPI = new OpenAPIParser()
|
||||||
.readLocation("src/test/resources/bugs/issue_14917.yaml", null, new ParseOptions())
|
.readLocation("src/test/resources/bugs/issue_14917.yaml", null, new ParseOptions())
|
||||||
@ -1834,7 +1887,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void shouldProperlyExplodeRestTemplateQueryParameters_issue907() {
|
@Test
|
||||||
|
public void shouldProperlyExplodeRestTemplateQueryParameters_issue907() {
|
||||||
|
|
||||||
final Map<String, File> files = generateFromContract(
|
final Map<String, File> files = generateFromContract(
|
||||||
"src/test/resources/3_0/java/explode-query-parameter.yaml",
|
"src/test/resources/3_0/java/explode-query-parameter.yaml",
|
||||||
@ -1892,7 +1946,8 @@ public class JavaClientCodegenTest {
|
|||||||
final String library,
|
final String library,
|
||||||
final Map<String, Object> properties
|
final Map<String, Object> properties
|
||||||
) {
|
) {
|
||||||
return generateFromContract(pathToSpecification, library, properties, configurator -> {});
|
return generateFromContract(pathToSpecification, library, properties, configurator -> {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@ -1915,7 +1970,8 @@ public class JavaClientCodegenTest {
|
|||||||
.stream().collect(Collectors.toMap(File::getName, Function.identity()));
|
.stream().collect(Collectors.toMap(File::getName, Function.identity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testForJavaApacheHttpClientJsonSubtype() {
|
@Test
|
||||||
|
public void testForJavaApacheHttpClientJsonSubtype() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
OpenAPI openAPI = new OpenAPIParser()
|
OpenAPI openAPI = new OpenAPIParser()
|
||||||
.readLocation("src/test/resources/bugs/issue_14917.yaml", null, new ParseOptions())
|
.readLocation("src/test/resources/bugs/issue_14917.yaml", null, new ParseOptions())
|
||||||
@ -1952,7 +2008,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testIsOverriddenProperty() {
|
@Test
|
||||||
|
public void testIsOverriddenProperty() {
|
||||||
final OpenAPI openAPI =
|
final OpenAPI openAPI =
|
||||||
TestUtils.parseFlattenSpec("src/test/resources/3_0/allOf_composition_discriminator.yaml");
|
TestUtils.parseFlattenSpec("src/test/resources/3_0/allOf_composition_discriminator.yaml");
|
||||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
@ -1969,7 +2026,8 @@ public class JavaClientCodegenTest {
|
|||||||
Assertions.assertEquals(cp1.isOverridden, false);
|
Assertions.assertEquals(cp1.isOverridden, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testForJavaApacheHttpClientOverrideSetter() {
|
@Test
|
||||||
|
public void testForJavaApacheHttpClientOverrideSetter() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
OpenAPI openAPI = new OpenAPIParser()
|
OpenAPI openAPI = new OpenAPIParser()
|
||||||
.readLocation("src/test/resources/3_0/allOf_composition_discriminator.yaml", null, null)
|
.readLocation("src/test/resources/3_0/allOf_composition_discriminator.yaml", null, null)
|
||||||
@ -1987,7 +2045,8 @@ public class JavaClientCodegenTest {
|
|||||||
.contains(" }\n" + "\n" + " public Pet petType(@javax.annotation.Nonnull String petType) {\n");
|
.contains(" }\n" + "\n" + " public Pet petType(@javax.annotation.Nonnull String petType) {\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testForJavaNativeClientOverrideSetter() {
|
@Test
|
||||||
|
public void testForJavaNativeClientOverrideSetter() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final OpenAPI openAPI = new OpenAPIParser()
|
final OpenAPI openAPI = new OpenAPIParser()
|
||||||
.readLocation("src/test/resources/3_0/allOf_composition_discriminator.yaml", null, null)
|
.readLocation("src/test/resources/3_0/allOf_composition_discriminator.yaml", null, null)
|
||||||
@ -2004,7 +2063,8 @@ public class JavaClientCodegenTest {
|
|||||||
.contains(" }\n" + "\n" + " public Pet petType(@javax.annotation.Nonnull String petType) {\n");
|
.contains(" }\n" + "\n" + " public Pet petType(@javax.annotation.Nonnull String petType) {\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testDeprecatedProperty() {
|
@Test
|
||||||
|
public void testDeprecatedProperty() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2023,7 +2083,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testDeprecatedPropertyJersey3() {
|
@Test
|
||||||
|
public void testDeprecatedPropertyJersey3() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2074,7 +2135,8 @@ public class JavaClientCodegenTest {
|
|||||||
.containsWithName("annotation2");
|
.containsWithName("annotation2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestTemplateWithGeneratedClientAsBeanDisabled() {
|
@Test
|
||||||
|
public void testRestTemplateWithGeneratedClientAsBeanDisabled() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2091,7 +2153,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileNotContains(output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"), "@Component");
|
TestUtils.assertFileNotContains(output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"), "@Component");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestTemplateWithGeneratedClientAsBeanEnabled() {
|
@Test
|
||||||
|
public void testRestTemplateWithGeneratedClientAsBeanEnabled() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2108,7 +2171,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileContains(output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"), "@Component");
|
TestUtils.assertFileContains(output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"), "@Component");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestTemplateWithUseBeanValidationEnabled() {
|
@Test
|
||||||
|
public void testRestTemplateWithUseBeanValidationEnabled() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2125,7 +2189,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileContains(output.resolve("src/main/java/org/openapitools/client/model/Pet.java"), "@Valid");
|
TestUtils.assertFileContains(output.resolve("src/main/java/org/openapitools/client/model/Pet.java"), "@Valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestTemplateWithUseBeanValidationDisabled() {
|
@Test
|
||||||
|
public void testRestTemplateWithUseBeanValidationDisabled() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2142,7 +2207,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileNotContains(output.resolve("src/main/java/org/openapitools/client/model/Pet.java"), "@Valid");
|
TestUtils.assertFileNotContains(output.resolve("src/main/java/org/openapitools/client/model/Pet.java"), "@Valid");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestTemplateWithPerformBeanValidationEnabled() {
|
@Test
|
||||||
|
public void testRestTemplateWithPerformBeanValidationEnabled() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2159,7 +2225,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileExists(output.resolve("src/main/java/xyz/abcdef/BeanValidationException.java"));
|
TestUtils.assertFileExists(output.resolve("src/main/java/xyz/abcdef/BeanValidationException.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestTemplateWithPerformBeanValidationDisabled() {
|
@Test
|
||||||
|
public void testRestTemplateWithPerformBeanValidationDisabled() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2176,7 +2243,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileNotExists(output.resolve("src/main/java/org/openapitools/client/invoker/BeanValidationException.java"));
|
TestUtils.assertFileNotExists(output.resolve("src/main/java/org/openapitools/client/invoker/BeanValidationException.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testLogicToAvoidStackOverflow() {
|
@Test
|
||||||
|
public void testLogicToAvoidStackOverflow() {
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
.addAdditionalProperty(CodegenConstants.API_PACKAGE, "xyz.abcdef.api")
|
.addAdditionalProperty(CodegenConstants.API_PACKAGE, "xyz.abcdef.api")
|
||||||
@ -2190,7 +2258,8 @@ public class JavaClientCodegenTest {
|
|||||||
// shouldn't throw stackoverflow exception
|
// shouldn't throw stackoverflow exception
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testWebClientSupportListOfStringReturnType_issue7118() {
|
@Test
|
||||||
|
public void testWebClientSupportListOfStringReturnType_issue7118() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2216,7 +2285,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testEnumCaseInsensitive_issue8084() {
|
@Test
|
||||||
|
public void testEnumCaseInsensitive_issue8084() {
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/issue8084.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/issue8084.yaml");
|
||||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
@ -2231,7 +2301,8 @@ public class JavaClientCodegenTest {
|
|||||||
.bodyContainsLines("if (b.value.equalsIgnoreCase(value)) {");
|
.bodyContainsLines("if (b.value.equalsIgnoreCase(value)) {");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testEnumCaseSensitive_issue8084() {
|
@Test
|
||||||
|
public void testEnumCaseSensitive_issue8084() {
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/issue8084.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/issue8084.yaml");
|
||||||
final JavaClientCodegen codegen = new JavaClientCodegen();
|
final JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
codegen.setOpenAPI(openAPI);
|
codegen.setOpenAPI(openAPI);
|
||||||
@ -2246,7 +2317,8 @@ public class JavaClientCodegenTest {
|
|||||||
.bodyContainsLines("if (b.value.equals(value)) {");
|
.bodyContainsLines("if (b.value.equals(value)) {");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testWebClientResponseTypeWithUseAbstractionForFiles_issue16589() {
|
@Test
|
||||||
|
public void testWebClientResponseTypeWithUseAbstractionForFiles_issue16589() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2266,7 +2338,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testHandleConstantParams() {
|
@Test
|
||||||
|
public void testHandleConstantParams() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/java/autoset_constant.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/java/autoset_constant.yaml");
|
||||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
@ -2298,7 +2371,8 @@ public class JavaClientCodegenTest {
|
|||||||
assertNull(files.get("AllOfDatetime.java"));
|
assertNull(files.get("AllOfDatetime.java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testOpenapiGeneratorIgnoreListOption() {
|
@Test
|
||||||
|
public void testOpenapiGeneratorIgnoreListOption() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/allof_primitive.yaml");
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/allof_primitive.yaml");
|
||||||
JavaClientCodegen codegen = new JavaClientCodegen();
|
JavaClientCodegen codegen = new JavaClientCodegen();
|
||||||
@ -2317,12 +2391,12 @@ public class JavaClientCodegenTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRestTemplateHandleURIEnum() {
|
public void testRestTemplateHandleURIEnum() {
|
||||||
String[] expectedInnerEnumLines = new String[] {
|
String[] expectedInnerEnumLines = new String[]{
|
||||||
"V1_SCHEMA_JSON(URI.create(\"https://example.com/v1/schema.json\"))",
|
"V1_SCHEMA_JSON(URI.create(\"https://example.com/v1/schema.json\"))",
|
||||||
"V2_SCHEMA_JSON(URI.create(\"https://example.com/v2/schema.json\"))"
|
"V2_SCHEMA_JSON(URI.create(\"https://example.com/v2/schema.json\"))"
|
||||||
};
|
};
|
||||||
|
|
||||||
String[] expectedEnumLines = new String[] {
|
String[] expectedEnumLines = new String[]{
|
||||||
"V1_METADATA_JSON(URI.create(\"https://example.com/v1/metadata.json\"))",
|
"V1_METADATA_JSON(URI.create(\"https://example.com/v1/metadata.json\"))",
|
||||||
"V2_METADATA_JSON(URI.create(\"https://example.com/v2/metadata.json\"))"
|
"V2_METADATA_JSON(URI.create(\"https://example.com/v2/metadata.json\"))"
|
||||||
};
|
};
|
||||||
@ -2332,7 +2406,7 @@ public class JavaClientCodegenTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOkHttpGsonHandleURIEnum() {
|
public void testOkHttpGsonHandleURIEnum() {
|
||||||
String[] expectedInnerEnumLines = new String[] {
|
String[] expectedInnerEnumLines = new String[]{
|
||||||
"V1_SCHEMA_JSON(URI.create(\"https://example.com/v1/schema.json\"))",
|
"V1_SCHEMA_JSON(URI.create(\"https://example.com/v1/schema.json\"))",
|
||||||
"V2_SCHEMA_JSON(URI.create(\"https://example.com/v2/schema.json\"))",
|
"V2_SCHEMA_JSON(URI.create(\"https://example.com/v2/schema.json\"))",
|
||||||
"jsonWriter.value(enumeration.getValue().toASCIIString())",
|
"jsonWriter.value(enumeration.getValue().toASCIIString())",
|
||||||
@ -2340,7 +2414,7 @@ public class JavaClientCodegenTest {
|
|||||||
"URI value = URI.create(jsonElement.getAsString())"
|
"URI value = URI.create(jsonElement.getAsString())"
|
||||||
};
|
};
|
||||||
|
|
||||||
String[] expectedEnumLines = new String[] {
|
String[] expectedEnumLines = new String[]{
|
||||||
"V1_METADATA_JSON(URI.create(\"https://example.com/v1/metadata.json\"))",
|
"V1_METADATA_JSON(URI.create(\"https://example.com/v1/metadata.json\"))",
|
||||||
"V2_METADATA_JSON(URI.create(\"https://example.com/v2/metadata.json\"))",
|
"V2_METADATA_JSON(URI.create(\"https://example.com/v2/metadata.json\"))",
|
||||||
"jsonWriter.value(enumeration.getValue().toASCIIString())",
|
"jsonWriter.value(enumeration.getValue().toASCIIString())",
|
||||||
@ -2353,13 +2427,13 @@ public class JavaClientCodegenTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMicroprofileHandleURIEnum() {
|
public void testMicroprofileHandleURIEnum() {
|
||||||
String[] expectedInnerEnumLines = new String[] {
|
String[] expectedInnerEnumLines = new String[]{
|
||||||
"V1_SCHEMA_JSON(URI.create(\"https://example.com/v1/schema.json\"))",
|
"V1_SCHEMA_JSON(URI.create(\"https://example.com/v1/schema.json\"))",
|
||||||
"V2_SCHEMA_JSON(URI.create(\"https://example.com/v2/schema.json\"))",
|
"V2_SCHEMA_JSON(URI.create(\"https://example.com/v2/schema.json\"))",
|
||||||
"generator.write(obj.value.toASCIIString())"
|
"generator.write(obj.value.toASCIIString())"
|
||||||
};
|
};
|
||||||
|
|
||||||
String[] expectedEnumLines = new String[] {
|
String[] expectedEnumLines = new String[]{
|
||||||
"V1_METADATA_JSON(URI.create(\"https://example.com/v1/metadata.json\"))",
|
"V1_METADATA_JSON(URI.create(\"https://example.com/v1/metadata.json\"))",
|
||||||
"V2_METADATA_JSON(URI.create(\"https://example.com/v2/metadata.json\"))"
|
"V2_METADATA_JSON(URI.create(\"https://example.com/v2/metadata.json\"))"
|
||||||
};
|
};
|
||||||
@ -2389,7 +2463,8 @@ public class JavaClientCodegenTest {
|
|||||||
JavaFileAssert.assertThat(apiFile).fileContains(expectedInnerEnumLines);
|
JavaFileAssert.assertThat(apiFile).fileContains(expectedInnerEnumLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testQueryParamsExploded_whenQueryParamIsNull() {
|
@Test
|
||||||
|
public void testQueryParamsExploded_whenQueryParamIsNull() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2404,7 +2479,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileContains(output.resolve("src/main/java/xyz/abcdef/api/DepartmentApi.java"), "if (filter != null) {");
|
TestUtils.assertFileContains(output.resolve("src/main/java/xyz/abcdef/api/DepartmentApi.java"), "if (filter != null) {");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void generateAllArgsConstructor() {
|
@Test
|
||||||
|
public void generateAllArgsConstructor() {
|
||||||
Map<String, File> files = generateFromContract("src/test/resources/3_0/java/all_args_constructor.yaml", JavaClientCodegen.RESTTEMPLATE,
|
Map<String, File> files = generateFromContract("src/test/resources/3_0/java/all_args_constructor.yaml", JavaClientCodegen.RESTTEMPLATE,
|
||||||
Map.of(AbstractJavaCodegen.GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, Boolean.TRUE),
|
Map.of(AbstractJavaCodegen.GENERATE_CONSTRUCTOR_WITH_ALL_ARGS, Boolean.TRUE),
|
||||||
codegenConfigurator -> codegenConfigurator.addOpenapiNormalizer("REFACTOR_ALLOF_WITH_PROPERTIES_ONLY", "false"));
|
codegenConfigurator -> codegenConfigurator.addOpenapiNormalizer("REFACTOR_ALLOF_WITH_PROPERTIES_ONLY", "false"));
|
||||||
@ -2435,7 +2511,8 @@ public class JavaClientCodegenTest {
|
|||||||
.hasParameter("_list").toConstructor();
|
.hasParameter("_list").toConstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void generateAllArgsConstructor_REFACTOR_ALLOF_WITH_PROPERTIES_ONLY() {
|
@Test
|
||||||
|
public void generateAllArgsConstructor_REFACTOR_ALLOF_WITH_PROPERTIES_ONLY() {
|
||||||
// try the generation with some additional OpenAPINormalizers
|
// try the generation with some additional OpenAPINormalizers
|
||||||
|
|
||||||
Map<String, File> files = generateFromContract("src/test/resources/3_0/java/all_args_constructor.yaml", JavaClientCodegen.RESTTEMPLATE,
|
Map<String, File> files = generateFromContract("src/test/resources/3_0/java/all_args_constructor.yaml", JavaClientCodegen.RESTTEMPLATE,
|
||||||
@ -2463,7 +2540,8 @@ public class JavaClientCodegenTest {
|
|||||||
.assertConstructor("Integer", "String", "LocalDate", "String", "String");
|
.assertConstructor("Integer", "String", "LocalDate", "String", "String");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientFormMultipart() {
|
@Test
|
||||||
|
public void testRestClientFormMultipart() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2492,7 +2570,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientWithUseAbstractionForFiles() {
|
@Test
|
||||||
|
public void testRestClientWithUseAbstractionForFiles() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2521,7 +2600,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientWithFreeFormInQueryParameters() {
|
@Test
|
||||||
|
public void testRestClientWithFreeFormInQueryParameters() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
|
final CodegenConfigurator configurator = new CodegenConfigurator().setGeneratorName("java")
|
||||||
.setLibrary(JavaClientCodegen.RESTCLIENT)
|
.setLibrary(JavaClientCodegen.RESTCLIENT)
|
||||||
@ -2535,7 +2615,8 @@ public class JavaClientCodegenTest {
|
|||||||
TestUtils.assertFileContains(output.resolve("src/main/java/xyz/abcdef/ApiClient.java"), "value instanceof Map");
|
TestUtils.assertFileContains(output.resolve("src/main/java/xyz/abcdef/ApiClient.java"), "value instanceof Map");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientJsonCreatorWithNullable_issue12790() {
|
@Test
|
||||||
|
public void testRestClientJsonCreatorWithNullable_issue12790() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.addAdditionalProperty(AbstractJavaCodegen.OPENAPI_NULLABLE, "true")
|
.addAdditionalProperty(AbstractJavaCodegen.OPENAPI_NULLABLE, "true")
|
||||||
@ -2557,7 +2638,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientSupportListOfStringReturnType_issue7118() {
|
@Test
|
||||||
|
public void testRestClientSupportListOfStringReturnType_issue7118() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2583,7 +2665,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientResponseTypeWithUseAbstractionForFiles_issue16589() {
|
@Test
|
||||||
|
public void testRestClientResponseTypeWithUseAbstractionForFiles_issue16589() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -2604,7 +2687,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test void testBuilderJavaClient() {
|
@Test
|
||||||
|
void testBuilderJavaClient() {
|
||||||
Map<String, File> files = generateFromContract(
|
Map<String, File> files = generateFromContract(
|
||||||
"src/test/resources/3_0/java/builder.yaml",
|
"src/test/resources/3_0/java/builder.yaml",
|
||||||
JavaClientCodegen.RESTTEMPLATE,
|
JavaClientCodegen.RESTTEMPLATE,
|
||||||
@ -2626,11 +2710,13 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DataProvider Iterator<String> serializationLibraries() {
|
@DataProvider
|
||||||
|
Iterator<String> serializationLibraries() {
|
||||||
return new JavaClientCodegen().supportedLibraries().keySet().iterator();
|
return new JavaClientCodegen().supportedLibraries().keySet().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dataProvider = "serializationLibraries") void setsDefaultSerializationLibrary(String library) {
|
@Test(dataProvider = "serializationLibraries")
|
||||||
|
void setsDefaultSerializationLibrary(String library) {
|
||||||
var codegen = new JavaClientCodegen();
|
var codegen = new JavaClientCodegen();
|
||||||
codegen.setLibrary(library);
|
codegen.setLibrary(library);
|
||||||
codegen.processOpts();
|
codegen.processOpts();
|
||||||
@ -2648,7 +2734,8 @@ public class JavaClientCodegenTest {
|
|||||||
* When GSON is selected as serializer, there should not be any jackson references
|
* When GSON is selected as serializer, there should not be any jackson references
|
||||||
* (except jackson-databind-nullable that is, which is only added when openApiNullable=true)
|
* (except jackson-databind-nullable that is, which is only added when openApiNullable=true)
|
||||||
*/
|
*/
|
||||||
@Test(dataProvider = "librariesSupportingGson") void gsonCodeDoesNotContainJacksonReferences(Library library) {
|
@Test(dataProvider = "librariesSupportingGson")
|
||||||
|
void gsonCodeDoesNotContainJacksonReferences(Library library) {
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.addAdditionalProperty(SERIALIZATION_LIBRARY, Serializer.GSON)
|
.addAdditionalProperty(SERIALIZATION_LIBRARY, Serializer.GSON)
|
||||||
.addAdditionalProperty(OPENAPI_NULLABLE, "false")
|
.addAdditionalProperty(OPENAPI_NULLABLE, "false")
|
||||||
@ -2669,7 +2756,8 @@ public class JavaClientCodegenTest {
|
|||||||
/**
|
/**
|
||||||
* Regression test for <a href="https://github.com/OpenAPITools/openapi-generator/issues/6496">#6496</a>
|
* Regression test for <a href="https://github.com/OpenAPITools/openapi-generator/issues/6496">#6496</a>
|
||||||
*/
|
*/
|
||||||
@Test void doesNotGenerateJacksonJsonFormatAnnotation_whenLibraryIsGson_andSerializeBigDecimalAsStringIsTrue() {
|
@Test
|
||||||
|
void doesNotGenerateJacksonJsonFormatAnnotation_whenLibraryIsGson_andSerializeBigDecimalAsStringIsTrue() {
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
.setLibrary(JavaClientCodegen.OKHTTP_GSON)
|
.setLibrary(JavaClientCodegen.OKHTTP_GSON)
|
||||||
@ -2695,7 +2783,8 @@ public class JavaClientCodegenTest {
|
|||||||
* Test that fix for <a href="https://github.com/OpenAPITools/openapi-generator/issues/6496">#6496</a> has
|
* Test that fix for <a href="https://github.com/OpenAPITools/openapi-generator/issues/6496">#6496</a> has
|
||||||
* no unwanted side effects on the existing feature (Jackson + bigDecimalAsString)
|
* no unwanted side effects on the existing feature (Jackson + bigDecimalAsString)
|
||||||
*/
|
*/
|
||||||
@Test void generatesJacksonJsonFormatAnnotation_whenLibraryIsJackson_andSerializeBigDecimalAsStringIsTrue() {
|
@Test
|
||||||
|
void generatesJacksonJsonFormatAnnotation_whenLibraryIsJackson_andSerializeBigDecimalAsStringIsTrue() {
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
.setLibrary(JavaClientCodegen.NATIVE)
|
.setLibrary(JavaClientCodegen.NATIVE)
|
||||||
@ -3015,7 +3104,8 @@ public class JavaClientCodegenTest {
|
|||||||
.bodyContainsLines("headerParams.add(HttpHeaders.AUTHORIZATION, \"Bearer \" + accessToken)");
|
.bodyContainsLines("headerParams.add(HttpHeaders.AUTHORIZATION, \"Bearer \" + accessToken)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientWithXML_issue_19137() {
|
@Test
|
||||||
|
public void testRestClientWithXML_issue_19137() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -3037,7 +3127,8 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRestClientWithUseSingleRequestParameter_issue_19406() {
|
@Test
|
||||||
|
public void testRestClientWithUseSingleRequestParameter_issue_19406() {
|
||||||
final Path output = newTempFolder();
|
final Path output = newTempFolder();
|
||||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
.setGeneratorName("java")
|
.setGeneratorName("java")
|
||||||
@ -3063,4 +3154,41 @@ public class JavaClientCodegenTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDuplicatedOperationId() {
|
||||||
|
final Path output = newTempFolder();
|
||||||
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
|
.setValidateSpec(false)
|
||||||
|
.setGeneratorName("java")
|
||||||
|
.setLibrary(JavaClientCodegen.RESTCLIENT)
|
||||||
|
.setAdditionalProperties(Map.of(
|
||||||
|
CodegenConstants.API_PACKAGE, "xyz.abcdef.api",
|
||||||
|
CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, true
|
||||||
|
))
|
||||||
|
.setInputSpec("src/test/resources/3_0/duplicated_operationid.yaml")
|
||||||
|
.setOutputDir(output.toString().replace("\\", "/"));
|
||||||
|
|
||||||
|
new DefaultGenerator().opts(configurator.toClientOptInput()).generate();
|
||||||
|
|
||||||
|
TestUtils.assertFileContains(
|
||||||
|
output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"),
|
||||||
|
" void getObject("
|
||||||
|
);
|
||||||
|
|
||||||
|
TestUtils.assertFileContains(
|
||||||
|
output.resolve("src/main/java/xyz/abcdef/api/UserApi.java"),
|
||||||
|
" void getObject("
|
||||||
|
);
|
||||||
|
|
||||||
|
TestUtils.assertFileNotContains(
|
||||||
|
output.resolve("src/main/java/xyz/abcdef/api/UserApi.java"),
|
||||||
|
" void getObject_0("
|
||||||
|
);
|
||||||
|
|
||||||
|
TestUtils.assertFileNotContains(
|
||||||
|
output.resolve("src/main/java/xyz/abcdef/api/UserApi.java"),
|
||||||
|
" void getObject0("
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
servers:
|
||||||
|
- url: 'http://petstore.swagger.io/v2'
|
||||||
|
info:
|
||||||
|
description: A sample spec to test duplicated operationId
|
||||||
|
version: 1.0.0
|
||||||
|
title: OpenAPI Petstore
|
||||||
|
license:
|
||||||
|
name: Apache-2.0
|
||||||
|
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
|
||||||
|
paths:
|
||||||
|
'/pet/{petId}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Find pet by ID
|
||||||
|
description: Returns a single pet
|
||||||
|
operationId: getObject
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet to return
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
|
'/user/{username}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Get user by user name
|
||||||
|
description: ''
|
||||||
|
operationId: getObject
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: The name that needs to be fetched. Use user1 for testing.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
'400':
|
||||||
|
description: Invalid username supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
externalDocs:
|
||||||
|
description: Find out more about Swagger
|
||||||
|
url: 'http://swagger.io'
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user