From 4fc04b3eb9622371c044020838e2fca944956083 Mon Sep 17 00:00:00 2001 From: Mattias-Sehlstedt <60173714+Mattias-Sehlstedt@users.noreply.github.com> Date: Sat, 15 Feb 2025 16:18:02 +0100 Subject: [PATCH 1/4] Add so that the singleRequestParameter can be constructed one parameter at a time --- docs/generators/java-microprofile.md | 2 +- docs/generators/java.md | 2 +- .../codegen/languages/JavaClientCodegen.java | 2 +- .../Java/libraries/restclient/api.mustache | 29 ++ .../Java/libraries/webclient/api.mustache | 20 +- .../codegen/java/JavaClientCodegenTest.java | 69 +++- .../org/openapitools/client/api/FakeApi.java | 336 +++++++++++++++--- .../org/openapitools/client/api/PetApi.java | 97 ++++- .../org/openapitools/client/api/UserApi.java | 38 +- 9 files changed, 514 insertions(+), 81 deletions(-) diff --git a/docs/generators/java-microprofile.md b/docs/generators/java-microprofile.md index 978dba2030c5..d46dc94cf1c0 100644 --- a/docs/generators/java-microprofile.md +++ b/docs/generators/java-microprofile.md @@ -100,7 +100,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useRuntimeException|Use RuntimeException instead of Exception. Only jersey2, jersey3, okhttp-gson, vertx, microprofile support this option.| |false| |useRxJava2|Whether to use the RxJava2 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false| |useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false| -|useSingleRequestParameter|Setting this property to "true" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to "static" does the same as "true", but also makes the generated arguments class static. Only WebClient supports this option.| |false| +|useSingleRequestParameter|Setting this property to "true" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to "static" does the same as "true", but also makes the generated arguments class static with single parameter instantiation.| |false| |webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false| |withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| diff --git a/docs/generators/java.md b/docs/generators/java.md index 5038eb608aab..d89024f923d0 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -100,7 +100,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useRuntimeException|Use RuntimeException instead of Exception. Only jersey2, jersey3, okhttp-gson, vertx, microprofile support this option.| |false| |useRxJava2|Whether to use the RxJava2 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false| |useRxJava3|Whether to use the RxJava3 adapter with the retrofit2 library. IMPORTANT: This option has been deprecated.| |false| -|useSingleRequestParameter|Setting this property to "true" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to "static" does the same as "true", but also makes the generated arguments class static. Only WebClient supports this option.| |false| +|useSingleRequestParameter|Setting this property to "true" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to "static" does the same as "true", but also makes the generated arguments class static with single parameter instantiation.| |false| |webclientBlockingOperations|Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync| |false| |withAWSV4Signature|whether to include AWS v4 signature support (only available for okhttp-gson library)| |false| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java index 03af420a7b0f..174c387d7f42 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java @@ -237,7 +237,7 @@ public JavaClientCodegen() { cliOptions.add(CliOption.newString(CONFIG_KEY_FROM_CLASS_NAME, "If true, set tag as key in @RegisterRestClient. Default to false. Only `microprofile` supports this option.")); cliOptions.add(CliOption.newBoolean(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC + " Only jersey2, jersey3, native, okhttp-gson support this option.")); cliOptions.add(CliOption.newString(MICROPROFILE_REST_CLIENT_VERSION, "Version of MicroProfile Rest Client API.")); - cliOptions.add(CliOption.newString(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, "Setting this property to \"true\" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to \"static\" does the same as \"true\", but also makes the generated arguments class static. Only WebClient supports this option.").defaultValue("false")); + cliOptions.add(CliOption.newString(CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, "Setting this property to \"true\" will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter. ONLY jersey2, jersey3, okhttp-gson, microprofile, Spring RestClient, Spring WebClient support this option. Setting this property to \"static\" does the same as \"true\", but also makes the generated arguments class static with single parameter instantiation.").defaultValue("false")); cliOptions.add(CliOption.newBoolean(WEBCLIENT_BLOCKING_OPERATIONS, "Making all WebClient operations blocking(sync). Note that if on operation 'x-webclient-blocking: false' then such operation won't be sync", this.webclientBlockingOperations)); cliOptions.add(CliOption.newBoolean(GENERATE_CLIENT_AS_BEAN, "For resttemplate, configure whether to create `ApiClient.java` and Apis clients as bean (with `@Component` annotation).", this.generateClientAsBean)); cliOptions.add(CliOption.newBoolean(SUPPORT_URL_QUERY, "Generate toUrlQueryString in POJO (default to true). Available on `native`, `apache-httpclient` libraries.")); diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache index 567ae4983e1c..36d845b39a05 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache @@ -56,7 +56,36 @@ public class {{classname}} { {{#hasParams}} {{^hasSingleParam}} + {{^staticRequest}} public record {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){} + {{/staticRequest}} + {{#staticRequest}} + @lombok.EqualsAndHashCode + public static class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request { + {{#allParams}} + private final {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; + {{/allParams}} + + public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request() {} + + public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) { + {{#allParams}} + this.{{paramName}} = {{paramName}}; + {{/allParams}} + } + + {{#allParams}} + public {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}() { + return this.{{paramName}}; + } + public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request {{paramName}}({{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}) { + this.{{paramName}} = {{paramName}}; + return this; + } + + {{/allParams}} + } + {{/staticRequest}} /** * {{summary}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache index 4c88bf7b4111..eef63632e15a 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache @@ -54,22 +54,30 @@ public class {{classname}} { } {{#operation}}{{#singleRequestParameter}}{{#hasParams}}{{^hasSingleParam}} + @lombok.EqualsAndHashCode public {{#staticRequest}}static {{/staticRequest}}class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request { {{#allParams}} private final {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; {{/allParams}} + public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request() {} + public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) { - {{#allParams}} - this.{{paramName}} = {{paramName}}; - {{/allParams}} - } + {{#allParams}} + this.{{paramName}} = {{paramName}}; + {{/allParams}} + } - {{#allParams}} + {{#allParams}} public {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}() { return this.{{paramName}}; } - {{/allParams}} + public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request {{paramName}}({{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}) { + this.{{paramName}} = {{paramName}}; + return this; + } + + {{/allParams}} } /** diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index 86caacf810b7..5c79bcf4a283 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -3206,6 +3206,40 @@ public void testRestClientWithUseSingleRequestParameter_issue_19406() { ); } + @Test + public void testRestClientWithUseSingleRequestParameter_static_issue_20668() { + final Path output = newTempFolder(); + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("java") + .setLibrary(JavaClientCodegen.RESTCLIENT) + .setAdditionalProperties(Map.of( + CodegenConstants.API_PACKAGE, "xyz.abcdef.api", + CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, "static" + )) + .setInputSpec("src/test/resources/3_1/java/petstore.yaml") + .setOutputDir(output.toString().replace("\\", "/")); + + new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); + + TestUtils.assertFileContains( + output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"), + "public static class DeletePetRequest {", + "DeletePetRequest(Long petId, String apiKey)", + "Long petId()", + "DeletePetRequest petId(Long petId) {", + "String apiKey()", + "DeletePetRequest apiKey(String apiKey) {", + "public void deletePet(DeletePetRequest requestParameters) throws RestClientResponseException {", + "public ResponseEntity deletePetWithHttpInfo(DeletePetRequest requestParameters) throws RestClientResponseException {", + "public ResponseSpec deletePetWithResponseSpec(DeletePetRequest requestParameters) throws RestClientResponseException {", + "public void deletePet(Long petId, String apiKey) throws RestClientResponseException {", + "public ResponseEntity deletePetWithHttpInfo(Long petId, String apiKey) throws RestClientResponseException {", + "public ResponseSpec deletePetWithResponseSpec(Long petId, String apiKey) throws RestClientResponseException {" + ); + TestUtils.assertFileNotContains(output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"), + "public record DeletePetRequest(Long petId, String apiKey){}"); + } + @Test public void testDuplicatedOperationId() { final Path output = newTempFolder(); @@ -3243,7 +3277,8 @@ public void testDuplicatedOperationId() { ); } - @Test public void testWebClientWithUseSingleRequestParameter_issue_19407() { + @Test + public void testWebClientWithUseSingleRequestParameter_issue_19407() { final Path output = newTempFolder(); final CodegenConfigurator configurator = new CodegenConfigurator() .setGeneratorName("java") @@ -3301,6 +3336,38 @@ public void testDuplicatedOperationId() { ); } + @Test + public void testWebClientWithUseSingleRequestParameter_static_issue_20668() { + final Path output = newTempFolder(); + final CodegenConfigurator configurator = new CodegenConfigurator() + .setGeneratorName("java") + .setLibrary(JavaClientCodegen.WEBCLIENT) + .setAdditionalProperties(Map.of( + CodegenConstants.API_PACKAGE, "xyz.abcdef.api", + CodegenConstants.USE_SINGLE_REQUEST_PARAMETER, "static" + )) + .setInputSpec("src/test/resources/3_1/java/petstore.yaml") + .setOutputDir(output.toString().replace("\\", "/")); + + new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); + + TestUtils.assertFileContains( + output.resolve("src/main/java/xyz/abcdef/api/PetApi.java"), + "public static class DeletePetRequest {", + "DeletePetRequest(Long petId, String apiKey)", + "Long petId()", + "DeletePetRequest petId(Long petId) {", + "String apiKey()", + "DeletePetRequest apiKey(String apiKey) {", + "public Mono deletePet(DeletePetRequest requestParameters) throws WebClientResponseException {", + "public Mono> deletePetWithHttpInfo(DeletePetRequest requestParameters) throws WebClientResponseException {", + "public ResponseSpec deletePetWithResponseSpec(DeletePetRequest requestParameters) throws WebClientResponseException {", + "public Mono deletePet(Long petId, String apiKey) throws WebClientResponseException {", + "public Mono> deletePetWithHttpInfo(Long petId, String apiKey) throws WebClientResponseException {", + "public ResponseSpec deletePetWithResponseSpec(Long petId, String apiKey) throws WebClientResponseException {" + ); + } + @Test public void testGenerateParameterId() { final Path output = newTempFolder(); diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java index 285ce2642042..ab3ff0cd2356 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java @@ -191,26 +191,44 @@ public ResponseSpec fakeHealthGetWithResponseSpec() throws WebClientResponseExce return fakeHealthGetRequestCreation(); } + @lombok.EqualsAndHashCode public class FakeHttpSignatureTestRequest { private final Pet pet; private final String query1; private final String header1; + public FakeHttpSignatureTestRequest() {} + public FakeHttpSignatureTestRequest(Pet pet, String query1, String header1) { - this.pet = pet; - this.query1 = query1; - this.header1 = header1; - } + this.pet = pet; + this.query1 = query1; + this.header1 = header1; + } public Pet pet() { return this.pet; } + public FakeHttpSignatureTestRequest pet(Pet pet) { + this.pet = pet; + return this; + } + public String query1() { return this.query1; } + public FakeHttpSignatureTestRequest query1(String query1) { + this.query1 = query1; + return this; + } + public String header1() { return this.header1; } + public FakeHttpSignatureTestRequest header1(String header1) { + this.header1 = header1; + return this; + } + } /** @@ -900,21 +918,34 @@ public ResponseSpec testBodyWithFileSchemaWithResponseSpec(FileSchemaTestClass f return testBodyWithFileSchemaRequestCreation(fileSchemaTestClass); } + @lombok.EqualsAndHashCode public class TestBodyWithQueryParamsRequest { private final String query; private final User user; + public TestBodyWithQueryParamsRequest() {} + public TestBodyWithQueryParamsRequest(String query, User user) { - this.query = query; - this.user = user; - } + this.query = query; + this.user = user; + } public String query() { return this.query; } + public TestBodyWithQueryParamsRequest query(String query) { + this.query = query; + return this; + } + public User user() { return this.user; } + public TestBodyWithQueryParamsRequest user(User user) { + this.user = user; + return this; + } + } /** @@ -1107,6 +1138,7 @@ public ResponseSpec testClientModelWithResponseSpec(Client client) throws WebCli return testClientModelRequestCreation(client); } + @lombok.EqualsAndHashCode public class TestEndpointParametersRequest { private final BigDecimal number; private final Double _double; @@ -1123,65 +1155,137 @@ public class TestEndpointParametersRequest { private final String password; private final String paramCallback; + public TestEndpointParametersRequest() {} + public TestEndpointParametersRequest(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, File binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) { - this.number = number; - this._double = _double; - this.patternWithoutDelimiter = patternWithoutDelimiter; - this._byte = _byte; - this.integer = integer; - this.int32 = int32; - this.int64 = int64; - this._float = _float; - this.string = string; - this.binary = binary; - this.date = date; - this.dateTime = dateTime; - this.password = password; - this.paramCallback = paramCallback; - } + this.number = number; + this._double = _double; + this.patternWithoutDelimiter = patternWithoutDelimiter; + this._byte = _byte; + this.integer = integer; + this.int32 = int32; + this.int64 = int64; + this._float = _float; + this.string = string; + this.binary = binary; + this.date = date; + this.dateTime = dateTime; + this.password = password; + this.paramCallback = paramCallback; + } public BigDecimal number() { return this.number; } + public TestEndpointParametersRequest number(BigDecimal number) { + this.number = number; + return this; + } + public Double _double() { return this._double; } + public TestEndpointParametersRequest _double(Double _double) { + this._double = _double; + return this; + } + public String patternWithoutDelimiter() { return this.patternWithoutDelimiter; } + public TestEndpointParametersRequest patternWithoutDelimiter(String patternWithoutDelimiter) { + this.patternWithoutDelimiter = patternWithoutDelimiter; + return this; + } + public byte[] _byte() { return this._byte; } + public TestEndpointParametersRequest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + public Integer integer() { return this.integer; } + public TestEndpointParametersRequest integer(Integer integer) { + this.integer = integer; + return this; + } + public Integer int32() { return this.int32; } + public TestEndpointParametersRequest int32(Integer int32) { + this.int32 = int32; + return this; + } + public Long int64() { return this.int64; } + public TestEndpointParametersRequest int64(Long int64) { + this.int64 = int64; + return this; + } + public Float _float() { return this._float; } + public TestEndpointParametersRequest _float(Float _float) { + this._float = _float; + return this; + } + public String string() { return this.string; } + public TestEndpointParametersRequest string(String string) { + this.string = string; + return this; + } + public File binary() { return this.binary; } + public TestEndpointParametersRequest binary(File binary) { + this.binary = binary; + return this; + } + public LocalDate date() { return this.date; } + public TestEndpointParametersRequest date(LocalDate date) { + this.date = date; + return this; + } + public OffsetDateTime dateTime() { return this.dateTime; } + public TestEndpointParametersRequest dateTime(OffsetDateTime dateTime) { + this.dateTime = dateTime; + return this; + } + public String password() { return this.password; } + public TestEndpointParametersRequest password(String password) { + this.password = password; + return this; + } + public String paramCallback() { return this.paramCallback; } + public TestEndpointParametersRequest paramCallback(String paramCallback) { + this.paramCallback = paramCallback; + return this; + } + } /** @@ -1389,6 +1493,7 @@ public ResponseSpec testEndpointParametersWithResponseSpec(BigDecimal number, Do return testEndpointParametersRequestCreation(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } + @lombok.EqualsAndHashCode public class TestEnumParametersRequest { private final List enumHeaderStringArray; private final String enumHeaderString; @@ -1400,45 +1505,92 @@ public class TestEnumParametersRequest { private final List enumFormStringArray; private final String enumFormString; + public TestEnumParametersRequest() {} + public TestEnumParametersRequest(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumQueryModelArray, List enumFormStringArray, String enumFormString) { - this.enumHeaderStringArray = enumHeaderStringArray; - this.enumHeaderString = enumHeaderString; - this.enumQueryStringArray = enumQueryStringArray; - this.enumQueryString = enumQueryString; - this.enumQueryInteger = enumQueryInteger; - this.enumQueryDouble = enumQueryDouble; - this.enumQueryModelArray = enumQueryModelArray; - this.enumFormStringArray = enumFormStringArray; - this.enumFormString = enumFormString; - } + this.enumHeaderStringArray = enumHeaderStringArray; + this.enumHeaderString = enumHeaderString; + this.enumQueryStringArray = enumQueryStringArray; + this.enumQueryString = enumQueryString; + this.enumQueryInteger = enumQueryInteger; + this.enumQueryDouble = enumQueryDouble; + this.enumQueryModelArray = enumQueryModelArray; + this.enumFormStringArray = enumFormStringArray; + this.enumFormString = enumFormString; + } public List enumHeaderStringArray() { return this.enumHeaderStringArray; } + public TestEnumParametersRequest enumHeaderStringArray(List enumHeaderStringArray) { + this.enumHeaderStringArray = enumHeaderStringArray; + return this; + } + public String enumHeaderString() { return this.enumHeaderString; } + public TestEnumParametersRequest enumHeaderString(String enumHeaderString) { + this.enumHeaderString = enumHeaderString; + return this; + } + public List enumQueryStringArray() { return this.enumQueryStringArray; } + public TestEnumParametersRequest enumQueryStringArray(List enumQueryStringArray) { + this.enumQueryStringArray = enumQueryStringArray; + return this; + } + public String enumQueryString() { return this.enumQueryString; } + public TestEnumParametersRequest enumQueryString(String enumQueryString) { + this.enumQueryString = enumQueryString; + return this; + } + public Integer enumQueryInteger() { return this.enumQueryInteger; } + public TestEnumParametersRequest enumQueryInteger(Integer enumQueryInteger) { + this.enumQueryInteger = enumQueryInteger; + return this; + } + public Double enumQueryDouble() { return this.enumQueryDouble; } + public TestEnumParametersRequest enumQueryDouble(Double enumQueryDouble) { + this.enumQueryDouble = enumQueryDouble; + return this; + } + public List enumQueryModelArray() { return this.enumQueryModelArray; } + public TestEnumParametersRequest enumQueryModelArray(List enumQueryModelArray) { + this.enumQueryModelArray = enumQueryModelArray; + return this; + } + public List enumFormStringArray() { return this.enumFormStringArray; } + public TestEnumParametersRequest enumFormStringArray(List enumFormStringArray) { + this.enumFormStringArray = enumFormStringArray; + return this; + } + public String enumFormString() { return this.enumFormString; } + public TestEnumParametersRequest enumFormString(String enumFormString) { + this.enumFormString = enumFormString; + return this; + } + } /** @@ -1597,6 +1749,7 @@ public ResponseSpec testEnumParametersWithResponseSpec(List enumHeaderSt return testEnumParametersRequestCreation(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString); } + @lombok.EqualsAndHashCode public class TestGroupParametersRequest { private final Integer requiredStringGroup; private final Boolean requiredBooleanGroup; @@ -1605,33 +1758,65 @@ public class TestGroupParametersRequest { private final Boolean booleanGroup; private final Long int64Group; + public TestGroupParametersRequest() {} + public TestGroupParametersRequest(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) { - this.requiredStringGroup = requiredStringGroup; - this.requiredBooleanGroup = requiredBooleanGroup; - this.requiredInt64Group = requiredInt64Group; - this.stringGroup = stringGroup; - this.booleanGroup = booleanGroup; - this.int64Group = int64Group; - } + this.requiredStringGroup = requiredStringGroup; + this.requiredBooleanGroup = requiredBooleanGroup; + this.requiredInt64Group = requiredInt64Group; + this.stringGroup = stringGroup; + this.booleanGroup = booleanGroup; + this.int64Group = int64Group; + } public Integer requiredStringGroup() { return this.requiredStringGroup; } + public TestGroupParametersRequest requiredStringGroup(Integer requiredStringGroup) { + this.requiredStringGroup = requiredStringGroup; + return this; + } + public Boolean requiredBooleanGroup() { return this.requiredBooleanGroup; } + public TestGroupParametersRequest requiredBooleanGroup(Boolean requiredBooleanGroup) { + this.requiredBooleanGroup = requiredBooleanGroup; + return this; + } + public Long requiredInt64Group() { return this.requiredInt64Group; } + public TestGroupParametersRequest requiredInt64Group(Long requiredInt64Group) { + this.requiredInt64Group = requiredInt64Group; + return this; + } + public Integer stringGroup() { return this.stringGroup; } + public TestGroupParametersRequest stringGroup(Integer stringGroup) { + this.stringGroup = stringGroup; + return this; + } + public Boolean booleanGroup() { return this.booleanGroup; } + public TestGroupParametersRequest booleanGroup(Boolean booleanGroup) { + this.booleanGroup = booleanGroup; + return this; + } + public Long int64Group() { return this.int64Group; } + public TestGroupParametersRequest int64Group(Long int64Group) { + this.int64Group = int64Group; + return this; + } + } /** @@ -1915,21 +2100,34 @@ public ResponseSpec testInlineFreeformAdditionalPropertiesWithResponseSpec(TestI return testInlineFreeformAdditionalPropertiesRequestCreation(testInlineFreeformAdditionalPropertiesRequest); } + @lombok.EqualsAndHashCode public class TestJsonFormDataRequest { private final String param; private final String param2; + public TestJsonFormDataRequest() {} + public TestJsonFormDataRequest(String param, String param2) { - this.param = param; - this.param2 = param2; - } + this.param = param; + this.param2 = param2; + } public String param() { return this.param; } + public TestJsonFormDataRequest param(String param) { + this.param = param; + return this; + } + public String param2() { return this.param2; } + public TestJsonFormDataRequest param2(String param2) { + this.param2 = param2; + return this; + } + } /** @@ -2120,6 +2318,7 @@ public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNull return testNullableRequestCreation(childWithNullable); } + @lombok.EqualsAndHashCode public class TestQueryParameterCollectionFormatRequest { private final List pipe; private final List ioutil; @@ -2129,37 +2328,74 @@ public class TestQueryParameterCollectionFormatRequest { private final String allowEmpty; private final Map language; + public TestQueryParameterCollectionFormatRequest() {} + public TestQueryParameterCollectionFormatRequest(List pipe, List ioutil, List http, List url, List context, String allowEmpty, Map language) { - this.pipe = pipe; - this.ioutil = ioutil; - this.http = http; - this.url = url; - this.context = context; - this.allowEmpty = allowEmpty; - this.language = language; - } + this.pipe = pipe; + this.ioutil = ioutil; + this.http = http; + this.url = url; + this.context = context; + this.allowEmpty = allowEmpty; + this.language = language; + } public List pipe() { return this.pipe; } + public TestQueryParameterCollectionFormatRequest pipe(List pipe) { + this.pipe = pipe; + return this; + } + public List ioutil() { return this.ioutil; } + public TestQueryParameterCollectionFormatRequest ioutil(List ioutil) { + this.ioutil = ioutil; + return this; + } + public List http() { return this.http; } + public TestQueryParameterCollectionFormatRequest http(List http) { + this.http = http; + return this; + } + public List url() { return this.url; } + public TestQueryParameterCollectionFormatRequest url(List url) { + this.url = url; + return this; + } + public List context() { return this.context; } + public TestQueryParameterCollectionFormatRequest context(List context) { + this.context = context; + return this; + } + public String allowEmpty() { return this.allowEmpty; } + public TestQueryParameterCollectionFormatRequest allowEmpty(String allowEmpty) { + this.allowEmpty = allowEmpty; + return this; + } + public Map language() { return this.language; } + public TestQueryParameterCollectionFormatRequest language(Map language) { + this.language = language; + return this; + } + } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java index ab7891d0b360..5ec9fcf6b3c6 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java @@ -124,21 +124,34 @@ public ResponseSpec addPetWithResponseSpec(Pet pet) throws WebClientResponseExce return addPetRequestCreation(pet); } + @lombok.EqualsAndHashCode public class DeletePetRequest { private final Long petId; private final String apiKey; + public DeletePetRequest() {} + public DeletePetRequest(Long petId, String apiKey) { - this.petId = petId; - this.apiKey = apiKey; - } + this.petId = petId; + this.apiKey = apiKey; + } public Long petId() { return this.petId; } + public DeletePetRequest petId(Long petId) { + this.petId = petId; + return this; + } + public String apiKey() { return this.apiKey; } + public DeletePetRequest apiKey(String apiKey) { + this.apiKey = apiKey; + return this; + } + } /** @@ -585,26 +598,44 @@ public ResponseSpec updatePetWithResponseSpec(Pet pet) throws WebClientResponseE return updatePetRequestCreation(pet); } + @lombok.EqualsAndHashCode public class UpdatePetWithFormRequest { private final Long petId; private final String name; private final String status; + public UpdatePetWithFormRequest() {} + public UpdatePetWithFormRequest(Long petId, String name, String status) { - this.petId = petId; - this.name = name; - this.status = status; - } + this.petId = petId; + this.name = name; + this.status = status; + } public Long petId() { return this.petId; } + public UpdatePetWithFormRequest petId(Long petId) { + this.petId = petId; + return this; + } + public String name() { return this.name; } + public UpdatePetWithFormRequest name(String name) { + this.name = name; + return this; + } + public String status() { return this.status; } + public UpdatePetWithFormRequest status(String status) { + this.status = status; + return this; + } + } /** @@ -734,26 +765,44 @@ public ResponseSpec updatePetWithFormWithResponseSpec(Long petId, String name, S return updatePetWithFormRequestCreation(petId, name, status); } + @lombok.EqualsAndHashCode public class UploadFileRequest { private final Long petId; private final String additionalMetadata; private final File _file; + public UploadFileRequest() {} + public UploadFileRequest(Long petId, String additionalMetadata, File _file) { - this.petId = petId; - this.additionalMetadata = additionalMetadata; - this._file = _file; - } + this.petId = petId; + this.additionalMetadata = additionalMetadata; + this._file = _file; + } public Long petId() { return this.petId; } + public UploadFileRequest petId(Long petId) { + this.petId = petId; + return this; + } + public String additionalMetadata() { return this.additionalMetadata; } + public UploadFileRequest additionalMetadata(String additionalMetadata) { + this.additionalMetadata = additionalMetadata; + return this; + } + public File _file() { return this._file; } + public UploadFileRequest _file(File _file) { + this._file = _file; + return this; + } + } /** @@ -883,26 +932,44 @@ public ResponseSpec uploadFileWithResponseSpec(Long petId, String additionalMeta return uploadFileRequestCreation(petId, additionalMetadata, _file); } + @lombok.EqualsAndHashCode public class UploadFileWithRequiredFileRequest { private final Long petId; private final File requiredFile; private final String additionalMetadata; + public UploadFileWithRequiredFileRequest() {} + public UploadFileWithRequiredFileRequest(Long petId, File requiredFile, String additionalMetadata) { - this.petId = petId; - this.requiredFile = requiredFile; - this.additionalMetadata = additionalMetadata; - } + this.petId = petId; + this.requiredFile = requiredFile; + this.additionalMetadata = additionalMetadata; + } public Long petId() { return this.petId; } + public UploadFileWithRequiredFileRequest petId(Long petId) { + this.petId = petId; + return this; + } + public File requiredFile() { return this.requiredFile; } + public UploadFileWithRequiredFileRequest requiredFile(File requiredFile) { + this.requiredFile = requiredFile; + return this; + } + public String additionalMetadata() { return this.additionalMetadata; } + public UploadFileWithRequiredFileRequest additionalMetadata(String additionalMetadata) { + this.additionalMetadata = additionalMetadata; + return this; + } + } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java index 006f7e661bcb..6d352487541d 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java @@ -415,21 +415,34 @@ public ResponseSpec getUserByNameWithResponseSpec(String username) throws WebCli return getUserByNameRequestCreation(username); } + @lombok.EqualsAndHashCode public class LoginUserRequest { private final String username; private final String password; + public LoginUserRequest() {} + public LoginUserRequest(String username, String password) { - this.username = username; - this.password = password; - } + this.username = username; + this.password = password; + } public String username() { return this.username; } + public LoginUserRequest username(String username) { + this.username = username; + return this; + } + public String password() { return this.password; } + public LoginUserRequest password(String password) { + this.password = password; + return this; + } + } /** @@ -620,21 +633,34 @@ public ResponseSpec logoutUserWithResponseSpec() throws WebClientResponseExcepti return logoutUserRequestCreation(); } + @lombok.EqualsAndHashCode public class UpdateUserRequest { private final String username; private final User user; + public UpdateUserRequest() {} + public UpdateUserRequest(String username, User user) { - this.username = username; - this.user = user; - } + this.username = username; + this.user = user; + } public String username() { return this.username; } + public UpdateUserRequest username(String username) { + this.username = username; + return this; + } + public User user() { return this.user; } + public UpdateUserRequest user(User user) { + this.user = user; + return this; + } + } /** From f88e043d61dbee6ffe2c7603f55ec1717a0a3995 Mon Sep 17 00:00:00 2001 From: Mattias-Sehlstedt <60173714+Mattias-Sehlstedt@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:46:22 +0100 Subject: [PATCH 2/4] Replace the lombok EqualsAndHashcode with a mustache implementation --- .../Java/libraries/restclient/api.mustache | 35 +++++- .../Java/libraries/webclient/api.mustache | 35 +++++- .../org/openapitools/client/api/FakeApi.java | 112 ++++++++++++++++-- .../org/openapitools/client/api/PetApi.java | 64 +++++++++- .../org/openapitools/client/api/UserApi.java | 32 ++++- 5 files changed, 263 insertions(+), 15 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache index 36d845b39a05..2dc5a4e73989 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache @@ -60,7 +60,6 @@ public class {{classname}} { public record {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request({{#allParams}}{{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){} {{/staticRequest}} {{#staticRequest}} - @lombok.EqualsAndHashCode public static class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request { {{#allParams}} private final {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; @@ -84,6 +83,40 @@ public class {{classname}} { } {{/allParams}} + @Override + public boolean equals(Object o) { + {{#useReflectionEqualsHashCode}} + return EqualsBuilder.reflectionEquals(this, o, false, null, true); + {{/useReflectionEqualsHashCode}} + {{^useReflectionEqualsHashCode}} + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + }{{#hasVars}} + {{classname}} {{classVarName}} = ({{classname}}) o; + return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} && + {{/-last}}{{/vars}}{{#additionalPropertiesType}} && + Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/additionalPropertiesType}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} + return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}} + {{/useReflectionEqualsHashCode}} + }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} + + @Override + public int hashCode() { + {{#useReflectionEqualsHashCode}} + return HashCodeBuilder.reflectionHashCode(this); + {{/useReflectionEqualsHashCode}} + {{^useReflectionEqualsHashCode}} + return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#additionalPropertiesType}}, additionalProperties{{/additionalPropertiesType}}); + {{/useReflectionEqualsHashCode}} + } } {{/staticRequest}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache index eef63632e15a..319bdabb1df4 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache @@ -54,7 +54,6 @@ public class {{classname}} { } {{#operation}}{{#singleRequestParameter}}{{#hasParams}}{{^hasSingleParam}} - @lombok.EqualsAndHashCode public {{#staticRequest}}static {{/staticRequest}}class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request { {{#allParams}} private final {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; @@ -78,6 +77,40 @@ public class {{classname}} { } {{/allParams}} + @Override + public boolean equals(Object o) { + {{#useReflectionEqualsHashCode}} + return EqualsBuilder.reflectionEquals(this, o, false, null, true); + {{/useReflectionEqualsHashCode}} + {{^useReflectionEqualsHashCode}} + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + }{{#hasVars}} + {{classname}} {{classVarName}} = ({{classname}}) o; + return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} && + {{/-last}}{{/vars}}{{#additionalPropertiesType}} && + Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/additionalPropertiesType}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} + return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}} + {{/useReflectionEqualsHashCode}} + }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} + + @Override + public int hashCode() { + {{#useReflectionEqualsHashCode}} + return HashCodeBuilder.reflectionHashCode(this); + {{/useReflectionEqualsHashCode}} + {{^useReflectionEqualsHashCode}} + return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#additionalPropertiesType}}, additionalProperties{{/additionalPropertiesType}}); + {{/useReflectionEqualsHashCode}} + } } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java index ab3ff0cd2356..f49e4e1b3b9c 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java @@ -191,7 +191,6 @@ public ResponseSpec fakeHealthGetWithResponseSpec() throws WebClientResponseExce return fakeHealthGetRequestCreation(); } - @lombok.EqualsAndHashCode public class FakeHttpSignatureTestRequest { private final Pet pet; private final String query1; @@ -229,6 +228,21 @@ public FakeHttpSignatureTestRequest header1(String header1) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -918,7 +932,6 @@ public ResponseSpec testBodyWithFileSchemaWithResponseSpec(FileSchemaTestClass f return testBodyWithFileSchemaRequestCreation(fileSchemaTestClass); } - @lombok.EqualsAndHashCode public class TestBodyWithQueryParamsRequest { private final String query; private final User user; @@ -946,6 +959,21 @@ public TestBodyWithQueryParamsRequest user(User user) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -1138,7 +1166,6 @@ public ResponseSpec testClientModelWithResponseSpec(Client client) throws WebCli return testClientModelRequestCreation(client); } - @lombok.EqualsAndHashCode public class TestEndpointParametersRequest { private final BigDecimal number; private final Double _double; @@ -1286,6 +1313,21 @@ public TestEndpointParametersRequest paramCallback(String paramCallback) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -1493,7 +1535,6 @@ public ResponseSpec testEndpointParametersWithResponseSpec(BigDecimal number, Do return testEndpointParametersRequestCreation(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); } - @lombok.EqualsAndHashCode public class TestEnumParametersRequest { private final List enumHeaderStringArray; private final String enumHeaderString; @@ -1591,6 +1632,21 @@ public TestEnumParametersRequest enumFormString(String enumFormString) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -1749,7 +1805,6 @@ public ResponseSpec testEnumParametersWithResponseSpec(List enumHeaderSt return testEnumParametersRequestCreation(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumQueryModelArray, enumFormStringArray, enumFormString); } - @lombok.EqualsAndHashCode public class TestGroupParametersRequest { private final Integer requiredStringGroup; private final Boolean requiredBooleanGroup; @@ -1817,6 +1872,21 @@ public TestGroupParametersRequest int64Group(Long int64Group) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -2100,7 +2170,6 @@ public ResponseSpec testInlineFreeformAdditionalPropertiesWithResponseSpec(TestI return testInlineFreeformAdditionalPropertiesRequestCreation(testInlineFreeformAdditionalPropertiesRequest); } - @lombok.EqualsAndHashCode public class TestJsonFormDataRequest { private final String param; private final String param2; @@ -2128,6 +2197,21 @@ public TestJsonFormDataRequest param2(String param2) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -2318,7 +2402,6 @@ public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNull return testNullableRequestCreation(childWithNullable); } - @lombok.EqualsAndHashCode public class TestQueryParameterCollectionFormatRequest { private final List pipe; private final List ioutil; @@ -2396,6 +2479,21 @@ public TestQueryParameterCollectionFormatRequest language(Map la return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java index 5ec9fcf6b3c6..07e66870b4d0 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java @@ -124,7 +124,6 @@ public ResponseSpec addPetWithResponseSpec(Pet pet) throws WebClientResponseExce return addPetRequestCreation(pet); } - @lombok.EqualsAndHashCode public class DeletePetRequest { private final Long petId; private final String apiKey; @@ -152,6 +151,21 @@ public DeletePetRequest apiKey(String apiKey) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -598,7 +612,6 @@ public ResponseSpec updatePetWithResponseSpec(Pet pet) throws WebClientResponseE return updatePetRequestCreation(pet); } - @lombok.EqualsAndHashCode public class UpdatePetWithFormRequest { private final Long petId; private final String name; @@ -636,6 +649,21 @@ public UpdatePetWithFormRequest status(String status) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -765,7 +793,6 @@ public ResponseSpec updatePetWithFormWithResponseSpec(Long petId, String name, S return updatePetWithFormRequestCreation(petId, name, status); } - @lombok.EqualsAndHashCode public class UploadFileRequest { private final Long petId; private final String additionalMetadata; @@ -803,6 +830,21 @@ public UploadFileRequest _file(File _file) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -932,7 +974,6 @@ public ResponseSpec uploadFileWithResponseSpec(Long petId, String additionalMeta return uploadFileRequestCreation(petId, additionalMetadata, _file); } - @lombok.EqualsAndHashCode public class UploadFileWithRequiredFileRequest { private final Long petId; private final File requiredFile; @@ -970,6 +1011,21 @@ public UploadFileWithRequiredFileRequest additionalMetadata(String additionalMet return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java index 6d352487541d..295139f670b9 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java @@ -415,7 +415,6 @@ public ResponseSpec getUserByNameWithResponseSpec(String username) throws WebCli return getUserByNameRequestCreation(username); } - @lombok.EqualsAndHashCode public class LoginUserRequest { private final String username; private final String password; @@ -443,6 +442,21 @@ public LoginUserRequest password(String password) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** @@ -633,7 +647,6 @@ public ResponseSpec logoutUserWithResponseSpec() throws WebClientResponseExcepti return logoutUserRequestCreation(); } - @lombok.EqualsAndHashCode public class UpdateUserRequest { private final String username; private final User user; @@ -661,6 +674,21 @@ public UpdateUserRequest user(User user) { return this; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } } /** From 074b355b8e2b8a42289116ee8bb95a6a48d1e377 Mon Sep 17 00:00:00 2001 From: Mattias-Sehlstedt <60173714+Mattias-Sehlstedt@users.noreply.github.com> Date: Tue, 18 Feb 2025 18:10:09 +0100 Subject: [PATCH 3/4] Remove equals and hashcode from oneRequestParameter model --- .../Java/libraries/restclient/api.mustache | 34 ------ .../Java/libraries/webclient/api.mustache | 34 ------ .../org/openapitools/client/api/FakeApi.java | 105 ------------------ .../org/openapitools/client/api/PetApi.java | 60 ---------- .../org/openapitools/client/api/UserApi.java | 30 ----- 5 files changed, 263 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache index 2dc5a4e73989..7fd2b0ce0c4d 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache @@ -83,40 +83,6 @@ public class {{classname}} { } {{/allParams}} - @Override - public boolean equals(Object o) { - {{#useReflectionEqualsHashCode}} - return EqualsBuilder.reflectionEquals(this, o, false, null, true); - {{/useReflectionEqualsHashCode}} - {{^useReflectionEqualsHashCode}} - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - }{{#hasVars}} - {{classname}} {{classVarName}} = ({{classname}}) o; - return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} && - {{/-last}}{{/vars}}{{#additionalPropertiesType}} && - Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/additionalPropertiesType}}{{#parent}} && - super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} - return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}} - {{/useReflectionEqualsHashCode}} - }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} - - @Override - public int hashCode() { - {{#useReflectionEqualsHashCode}} - return HashCodeBuilder.reflectionHashCode(this); - {{/useReflectionEqualsHashCode}} - {{^useReflectionEqualsHashCode}} - return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#additionalPropertiesType}}, additionalProperties{{/additionalPropertiesType}}); - {{/useReflectionEqualsHashCode}} - } } {{/staticRequest}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache index 319bdabb1df4..502d92ac31f6 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache @@ -77,40 +77,6 @@ public class {{classname}} { } {{/allParams}} - @Override - public boolean equals(Object o) { - {{#useReflectionEqualsHashCode}} - return EqualsBuilder.reflectionEquals(this, o, false, null, true); - {{/useReflectionEqualsHashCode}} - {{^useReflectionEqualsHashCode}} - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - }{{#hasVars}} - {{classname}} {{classVarName}} = ({{classname}}) o; - return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} && - {{/-last}}{{/vars}}{{#additionalPropertiesType}} && - Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/additionalPropertiesType}}{{#parent}} && - super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} - return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}} - {{/useReflectionEqualsHashCode}} - }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} - - private static boolean equalsNullable(JsonNullable a, JsonNullable b) { - return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); - }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} - - @Override - public int hashCode() { - {{#useReflectionEqualsHashCode}} - return HashCodeBuilder.reflectionHashCode(this); - {{/useReflectionEqualsHashCode}} - {{^useReflectionEqualsHashCode}} - return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#additionalPropertiesType}}, additionalProperties{{/additionalPropertiesType}}); - {{/useReflectionEqualsHashCode}} - } } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java index f49e4e1b3b9c..9c4bf293fd98 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java @@ -228,21 +228,6 @@ public FakeHttpSignatureTestRequest header1(String header1) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -959,21 +944,6 @@ public TestBodyWithQueryParamsRequest user(User user) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -1313,21 +1283,6 @@ public TestEndpointParametersRequest paramCallback(String paramCallback) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -1632,21 +1587,6 @@ public TestEnumParametersRequest enumFormString(String enumFormString) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -1872,21 +1812,6 @@ public TestGroupParametersRequest int64Group(Long int64Group) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -2197,21 +2122,6 @@ public TestJsonFormDataRequest param2(String param2) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -2479,21 +2389,6 @@ public TestQueryParameterCollectionFormatRequest language(Map la return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java index 07e66870b4d0..8aa984f97f75 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java @@ -151,21 +151,6 @@ public DeletePetRequest apiKey(String apiKey) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -649,21 +634,6 @@ public UpdatePetWithFormRequest status(String status) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -830,21 +800,6 @@ public UploadFileRequest _file(File _file) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -1011,21 +966,6 @@ public UploadFileWithRequiredFileRequest additionalMetadata(String additionalMet return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java index 295139f670b9..a53046ee6463 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java @@ -442,21 +442,6 @@ public LoginUserRequest password(String password) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** @@ -674,21 +659,6 @@ public UpdateUserRequest user(User user) { return this; } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(); - } } /** From 8bd85d880e2ee1edf70c1dade04cd280a597a4a4 Mon Sep 17 00:00:00 2001 From: Mattias-Sehlstedt <60173714+Mattias-Sehlstedt@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:39:59 +0100 Subject: [PATCH 4/4] Remove the final keyword from variables in the oneRequestParameter class --- .../Java/libraries/restclient/api.mustache | 2 +- .../Java/libraries/webclient/api.mustache | 2 +- .../org/openapitools/client/api/FakeApi.java | 86 +++++++++---------- .../org/openapitools/client/api/PetApi.java | 22 ++--- .../org/openapitools/client/api/UserApi.java | 8 +- 5 files changed, 60 insertions(+), 60 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache index 7fd2b0ce0c4d..0fff00ec80e2 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/restclient/api.mustache @@ -62,7 +62,7 @@ public class {{classname}} { {{#staticRequest}} public static class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request { {{#allParams}} - private final {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; + private {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; {{/allParams}} public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request() {} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache index 502d92ac31f6..0a412fb37ed6 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache @@ -56,7 +56,7 @@ public class {{classname}} { {{#operation}}{{#singleRequestParameter}}{{#hasParams}}{{^hasSingleParam}} public {{#staticRequest}}static {{/staticRequest}}class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request { {{#allParams}} - private final {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; + private {{#isFile}}{{#useAbstractionForFiles}}{{#collectionFormat}}java.util.Collection{{/collectionFormat}}{{^collectionFormat}}org.springframework.core.io.AbstractResource{{/collectionFormat}}{{/useAbstractionForFiles}}{{^useAbstractionForFiles}}{{{dataType}}}{{/useAbstractionForFiles}}{{/isFile}}{{^isFile}}{{{dataType}}}{{/isFile}} {{paramName}}; {{/allParams}} public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}Request() {} diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java index 9c4bf293fd98..0a164eef495a 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/FakeApi.java @@ -192,9 +192,9 @@ public ResponseSpec fakeHealthGetWithResponseSpec() throws WebClientResponseExce } public class FakeHttpSignatureTestRequest { - private final Pet pet; - private final String query1; - private final String header1; + private Pet pet; + private String query1; + private String header1; public FakeHttpSignatureTestRequest() {} @@ -918,8 +918,8 @@ public ResponseSpec testBodyWithFileSchemaWithResponseSpec(FileSchemaTestClass f } public class TestBodyWithQueryParamsRequest { - private final String query; - private final User user; + private String query; + private User user; public TestBodyWithQueryParamsRequest() {} @@ -1137,20 +1137,20 @@ public ResponseSpec testClientModelWithResponseSpec(Client client) throws WebCli } public class TestEndpointParametersRequest { - private final BigDecimal number; - private final Double _double; - private final String patternWithoutDelimiter; - private final byte[] _byte; - private final Integer integer; - private final Integer int32; - private final Long int64; - private final Float _float; - private final String string; - private final File binary; - private final LocalDate date; - private final OffsetDateTime dateTime; - private final String password; - private final String paramCallback; + private BigDecimal number; + private Double _double; + private String patternWithoutDelimiter; + private byte[] _byte; + private Integer integer; + private Integer int32; + private Long int64; + private Float _float; + private String string; + private File binary; + private LocalDate date; + private OffsetDateTime dateTime; + private String password; + private String paramCallback; public TestEndpointParametersRequest() {} @@ -1491,15 +1491,15 @@ public ResponseSpec testEndpointParametersWithResponseSpec(BigDecimal number, Do } public class TestEnumParametersRequest { - private final List enumHeaderStringArray; - private final String enumHeaderString; - private final List enumQueryStringArray; - private final String enumQueryString; - private final Integer enumQueryInteger; - private final Double enumQueryDouble; - private final List enumQueryModelArray; - private final List enumFormStringArray; - private final String enumFormString; + private List enumHeaderStringArray; + private String enumHeaderString; + private List enumQueryStringArray; + private String enumQueryString; + private Integer enumQueryInteger; + private Double enumQueryDouble; + private List enumQueryModelArray; + private List enumFormStringArray; + private String enumFormString; public TestEnumParametersRequest() {} @@ -1746,12 +1746,12 @@ public ResponseSpec testEnumParametersWithResponseSpec(List enumHeaderSt } public class TestGroupParametersRequest { - private final Integer requiredStringGroup; - private final Boolean requiredBooleanGroup; - private final Long requiredInt64Group; - private final Integer stringGroup; - private final Boolean booleanGroup; - private final Long int64Group; + private Integer requiredStringGroup; + private Boolean requiredBooleanGroup; + private Long requiredInt64Group; + private Integer stringGroup; + private Boolean booleanGroup; + private Long int64Group; public TestGroupParametersRequest() {} @@ -2096,8 +2096,8 @@ public ResponseSpec testInlineFreeformAdditionalPropertiesWithResponseSpec(TestI } public class TestJsonFormDataRequest { - private final String param; - private final String param2; + private String param; + private String param2; public TestJsonFormDataRequest() {} @@ -2313,13 +2313,13 @@ public ResponseSpec testNullableWithResponseSpec(ChildWithNullable childWithNull } public class TestQueryParameterCollectionFormatRequest { - private final List pipe; - private final List ioutil; - private final List http; - private final List url; - private final List context; - private final String allowEmpty; - private final Map language; + private List pipe; + private List ioutil; + private List http; + private List url; + private List context; + private String allowEmpty; + private Map language; public TestQueryParameterCollectionFormatRequest() {} diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java index 8aa984f97f75..7f126dfeddbc 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java @@ -125,8 +125,8 @@ public ResponseSpec addPetWithResponseSpec(Pet pet) throws WebClientResponseExce } public class DeletePetRequest { - private final Long petId; - private final String apiKey; + private Long petId; + private String apiKey; public DeletePetRequest() {} @@ -598,9 +598,9 @@ public ResponseSpec updatePetWithResponseSpec(Pet pet) throws WebClientResponseE } public class UpdatePetWithFormRequest { - private final Long petId; - private final String name; - private final String status; + private Long petId; + private String name; + private String status; public UpdatePetWithFormRequest() {} @@ -764,9 +764,9 @@ public ResponseSpec updatePetWithFormWithResponseSpec(Long petId, String name, S } public class UploadFileRequest { - private final Long petId; - private final String additionalMetadata; - private final File _file; + private Long petId; + private String additionalMetadata; + private File _file; public UploadFileRequest() {} @@ -930,9 +930,9 @@ public ResponseSpec uploadFileWithResponseSpec(Long petId, String additionalMeta } public class UploadFileWithRequiredFileRequest { - private final Long petId; - private final File requiredFile; - private final String additionalMetadata; + private Long petId; + private File requiredFile; + private String additionalMetadata; public UploadFileWithRequiredFileRequest() {} diff --git a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java index a53046ee6463..781ee3f5f401 100644 --- a/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/UserApi.java @@ -416,8 +416,8 @@ public ResponseSpec getUserByNameWithResponseSpec(String username) throws WebCli } public class LoginUserRequest { - private final String username; - private final String password; + private String username; + private String password; public LoginUserRequest() {} @@ -633,8 +633,8 @@ public ResponseSpec logoutUserWithResponseSpec() throws WebClientResponseExcepti } public class UpdateUserRequest { - private final String username; - private final User user; + private String username; + private User user; public UpdateUserRequest() {}