From 6cd7989e9e5e7e53d8f072479d1eae7765b70401 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Thu, 19 Jan 2023 16:13:51 +0800 Subject: [PATCH] [Java][native][apache-httpclient] Update toUrlQueryString to support form style for object (#14478) * update toUrlQueryString * add new files * minor bug fixes * support object in query parameter - java apache httpclient * rename variable - java native * update samples * fix try catch --- .../codegen/languages/JavaClientCodegen.java | 6 +- .../libraries/apache-httpclient/api.mustache | 13 +- .../Java/libraries/native/api.mustache | 17 +- .../Java/libraries/native/model.mustache | 4 +- .../Java/libraries/native/modelEnum.mustache | 4 +- .../Java/libraries/native/pojo.mustache | 58 +++- .../src/main/resources/Java/model.mustache | 4 +- .../main/resources/Java/modelEnum.mustache | 4 +- .../src/main/resources/Java/pojo.mustache | 61 +++- .../src/test/resources/3_0/echo_api.yaml | 56 ++++ .../.openapi-generator/FILES | 6 + .../echo_api/java/apache-httpclient/README.md | 4 + .../java/apache-httpclient/api/openapi.yaml | 61 ++++ .../java/apache-httpclient/docs/DataQuery.md | 15 + .../apache-httpclient/docs/DataQueryAllOf.md | 15 + .../java/apache-httpclient/docs/Query.md | 24 ++ .../java/apache-httpclient/docs/QueryApi.md | 67 +++++ .../org/openapitools/client/api/BodyApi.java | 4 +- .../org/openapitools/client/api/PathApi.java | 4 +- .../org/openapitools/client/api/QueryApi.java | 79 ++++- .../org/openapitools/client/model/Bird.java | 27 +- .../openapitools/client/model/Category.java | 27 +- .../openapitools/client/model/DataQuery.java | 267 +++++++++++++++++ .../client/model/DataQueryAllOf.java | 238 +++++++++++++++ .../org/openapitools/client/model/Pet.java | 42 ++- .../org/openapitools/client/model/Query.java | 245 ++++++++++++++++ .../org/openapitools/client/model/Tag.java | 27 +- ...deTrueObjectAllOfQueryObjectParameter.java | 33 ++- ...deTrueArrayStringQueryObjectParameter.java | 26 +- .../org/openapitools/client/CustomTest.java | 18 ++ .../client/model/DataQueryAllOfTest.java | 57 ++++ .../client/model/DataQueryTest.java | 76 +++++ .../openapitools/client/model/QueryTest.java | 58 ++++ .../java/feign-gson/.openapi-generator/FILES | 3 + .../echo_api/java/feign-gson/api/openapi.yaml | 61 ++++ .../org/openapitools/client/api/QueryApi.java | 78 +++++ .../openapitools/client/model/DataQuery.java | 160 ++++++++++ .../client/model/DataQueryAllOf.java | 154 ++++++++++ .../org/openapitools/client/model/Query.java | 184 ++++++++++++ .../client/model/DataQueryAllOfTest.java | 56 ++++ .../client/model/DataQueryTest.java | 75 +++++ .../openapitools/client/model/QueryTest.java | 57 ++++ .../java/native/.openapi-generator/FILES | 6 + samples/client/echo_api/java/native/README.md | 5 + .../echo_api/java/native/api/openapi.yaml | 61 ++++ .../echo_api/java/native/docs/DataQuery.md | 15 + .../java/native/docs/DataQueryAllOf.md | 15 + .../client/echo_api/java/native/docs/Query.md | 24 ++ .../echo_api/java/native/docs/QueryApi.md | 136 +++++++++ ...lodeTrueObjectAllOfQueryObjectParameter.md | 16 + .../org/openapitools/client/api/QueryApi.java | 135 +++++++-- .../org/openapitools/client/model/Bird.java | 23 +- .../openapitools/client/model/Category.java | 23 +- .../openapitools/client/model/DataQuery.java | 242 ++++++++++++++++ .../client/model/DataQueryAllOf.java | 223 ++++++++++++++ .../org/openapitools/client/model/Pet.java | 34 ++- .../org/openapitools/client/model/Query.java | 237 +++++++++++++++ .../org/openapitools/client/model/Tag.java | 23 +- ...deTrueObjectAllOfQueryObjectParameter.java | 27 +- ...deTrueArrayStringQueryObjectParameter.java | 23 +- ...deTrueObjectAllOfQueryObjectParameter.java | 239 +++++++++++++++ .../org/openapitools/client/CustomTest.java | 18 ++ .../client/model/DataQueryAllOfTest.java | 57 ++++ .../client/model/DataQueryTest.java | 76 +++++ .../openapitools/client/model/QueryTest.java | 58 ++++ ...ueObjectAllOfQueryObjectParameterTest.java | 72 +++++ .../java/okhttp-gson/.openapi-generator/FILES | 6 + .../echo_api/java/okhttp-gson/README.md | 4 + .../java/okhttp-gson/api/openapi.yaml | 61 ++++ .../java/okhttp-gson/docs/DataQuery.md | 15 + .../java/okhttp-gson/docs/DataQueryAllOf.md | 15 + .../echo_api/java/okhttp-gson/docs/Query.md | 24 ++ .../java/okhttp-gson/docs/QueryApi.md | 63 ++++ .../java/org/openapitools/client/JSON.java | 2 + .../org/openapitools/client/api/QueryApi.java | 122 ++++++++ .../openapitools/client/model/DataQuery.java | 274 ++++++++++++++++++ .../client/model/DataQueryAllOf.java | 267 +++++++++++++++++ .../org/openapitools/client/model/Query.java | 258 +++++++++++++++++ .../client/model/DataQueryAllOfTest.java | 57 ++++ .../client/model/DataQueryTest.java | 76 +++++ .../openapitools/client/model/QueryTest.java | 58 ++++ .../client/api/AnotherFakeApi.java | 4 +- .../openapitools/client/api/DefaultApi.java | 4 +- .../org/openapitools/client/api/FakeApi.java | 68 ++--- .../client/api/FakeClassnameTags123Api.java | 4 +- .../org/openapitools/client/api/PetApi.java | 36 +-- .../org/openapitools/client/api/StoreApi.java | 16 +- .../org/openapitools/client/api/UserApi.java | 32 +- .../model/AdditionalPropertiesClass.java | 31 +- .../client/model/AllOfWithSingleRef.java | 27 +- .../org/openapitools/client/model/Animal.java | 27 +- .../model/ArrayOfArrayOfNumberOnly.java | 26 +- .../client/model/ArrayOfNumberOnly.java | 26 +- .../openapitools/client/model/ArrayTest.java | 36 ++- .../client/model/Capitalization.java | 39 ++- .../org/openapitools/client/model/Cat.java | 30 +- .../openapitools/client/model/CatAllOf.java | 24 +- .../openapitools/client/model/Category.java | 27 +- .../openapitools/client/model/ClassModel.java | 24 +- .../org/openapitools/client/model/Client.java | 24 +- .../client/model/DeprecatedObject.java | 24 +- .../org/openapitools/client/model/Dog.java | 30 +- .../openapitools/client/model/DogAllOf.java | 24 +- .../openapitools/client/model/EnumArrays.java | 29 +- .../openapitools/client/model/EnumTest.java | 45 ++- .../client/model/FileSchemaTestClass.java | 28 +- .../org/openapitools/client/model/Foo.java | 24 +- .../client/model/FooGetDefaultResponse.java | 24 +- .../openapitools/client/model/FormatTest.java | 69 ++++- .../client/model/HasOnlyReadOnly.java | 27 +- .../client/model/HealthCheckResult.java | 24 +- .../openapitools/client/model/MapTest.java | 41 ++- ...ropertiesAndAdditionalPropertiesClass.java | 31 +- .../client/model/Model200Response.java | 27 +- .../client/model/ModelApiResponse.java | 30 +- .../openapitools/client/model/ModelFile.java | 24 +- .../openapitools/client/model/ModelList.java | 24 +- .../client/model/ModelReturn.java | 24 +- .../org/openapitools/client/model/Name.java | 33 ++- .../client/model/NullableClass.java | 69 ++++- .../openapitools/client/model/NumberOnly.java | 24 +- .../model/ObjectWithDeprecatedFields.java | 35 ++- .../org/openapitools/client/model/Order.java | 39 ++- .../client/model/OuterComposite.java | 30 +- .../model/OuterObjectWithEnumProperty.java | 24 +- .../org/openapitools/client/model/Pet.java | 42 ++- .../client/model/ReadOnlyFirst.java | 27 +- .../client/model/SpecialModelName.java | 24 +- .../org/openapitools/client/model/Tag.java | 27 +- .../org/openapitools/client/model/User.java | 45 ++- .../org/openapitools/client/api/FakeApi.java | 40 +-- .../org/openapitools/client/api/PetApi.java | 16 +- .../org/openapitools/client/api/UserApi.java | 8 +- .../model/AdditionalPropertiesClass.java | 27 +- .../client/model/AllOfWithSingleRef.java | 23 +- .../org/openapitools/client/model/Animal.java | 23 +- .../model/ArrayOfArrayOfNumberOnly.java | 23 +- .../client/model/ArrayOfNumberOnly.java | 23 +- .../openapitools/client/model/ArrayTest.java | 31 +- .../client/model/Capitalization.java | 31 +- .../org/openapitools/client/model/Cat.java | 25 +- .../openapitools/client/model/CatAllOf.java | 21 +- .../openapitools/client/model/Category.java | 23 +- .../openapitools/client/model/ClassModel.java | 21 +- .../org/openapitools/client/model/Client.java | 21 +- .../client/model/DeprecatedObject.java | 21 +- .../org/openapitools/client/model/Dog.java | 25 +- .../openapitools/client/model/DogAllOf.java | 21 +- .../openapitools/client/model/EnumArrays.java | 25 +- .../openapitools/client/model/EnumTest.java | 35 ++- .../client/model/FileSchemaTestClass.java | 24 +- .../org/openapitools/client/model/Foo.java | 21 +- .../client/model/FooGetDefaultResponse.java | 21 +- .../openapitools/client/model/FormatTest.java | 51 +++- .../client/model/HasOnlyReadOnly.java | 23 +- .../client/model/HealthCheckResult.java | 21 +- .../openapitools/client/model/MapTest.java | 35 ++- ...ropertiesAndAdditionalPropertiesClass.java | 26 +- .../client/model/Model200Response.java | 23 +- .../client/model/ModelApiResponse.java | 25 +- .../openapitools/client/model/ModelFile.java | 21 +- .../openapitools/client/model/ModelList.java | 21 +- .../client/model/ModelReturn.java | 21 +- .../org/openapitools/client/model/Name.java | 27 +- .../client/model/NullableClass.java | 55 +++- .../openapitools/client/model/NumberOnly.java | 21 +- .../model/ObjectWithDeprecatedFields.java | 29 +- .../org/openapitools/client/model/Order.java | 31 +- .../client/model/OuterComposite.java | 25 +- .../model/OuterObjectWithEnumProperty.java | 21 +- .../org/openapitools/client/model/Pet.java | 34 ++- .../client/model/ReadOnlyFirst.java | 23 +- .../client/model/SpecialModelName.java | 21 +- .../org/openapitools/client/model/Tag.java | 23 +- .../org/openapitools/client/model/User.java | 35 ++- .../org/openapitools/client/api/PetApi.java | 16 +- .../org/openapitools/client/api/UserApi.java | 8 +- .../openapitools/client/model/Category.java | 23 +- .../client/model/ModelApiResponse.java | 25 +- .../org/openapitools/client/model/Order.java | 31 +- .../org/openapitools/client/model/Pet.java | 34 ++- .../org/openapitools/client/model/Tag.java | 23 +- .../org/openapitools/client/model/User.java | 35 ++- .../org/openapitools/client/api/FakeApi.java | 40 +-- .../org/openapitools/client/api/PetApi.java | 16 +- .../org/openapitools/client/api/UserApi.java | 8 +- .../model/AdditionalPropertiesClass.java | 27 +- .../client/model/AllOfWithSingleRef.java | 23 +- .../org/openapitools/client/model/Animal.java | 23 +- .../model/ArrayOfArrayOfNumberOnly.java | 23 +- .../client/model/ArrayOfNumberOnly.java | 23 +- .../openapitools/client/model/ArrayTest.java | 31 +- .../client/model/Capitalization.java | 31 +- .../org/openapitools/client/model/Cat.java | 25 +- .../openapitools/client/model/CatAllOf.java | 21 +- .../openapitools/client/model/Category.java | 23 +- .../openapitools/client/model/ClassModel.java | 21 +- .../org/openapitools/client/model/Client.java | 21 +- .../client/model/DeprecatedObject.java | 21 +- .../org/openapitools/client/model/Dog.java | 25 +- .../openapitools/client/model/DogAllOf.java | 21 +- .../openapitools/client/model/EnumArrays.java | 25 +- .../openapitools/client/model/EnumTest.java | 35 ++- .../client/model/FileSchemaTestClass.java | 24 +- .../org/openapitools/client/model/Foo.java | 21 +- .../client/model/FooGetDefaultResponse.java | 21 +- .../openapitools/client/model/FormatTest.java | 51 +++- .../client/model/HasOnlyReadOnly.java | 23 +- .../client/model/HealthCheckResult.java | 21 +- .../openapitools/client/model/MapTest.java | 35 ++- ...ropertiesAndAdditionalPropertiesClass.java | 26 +- .../client/model/Model200Response.java | 23 +- .../client/model/ModelApiResponse.java | 25 +- .../openapitools/client/model/ModelFile.java | 21 +- .../openapitools/client/model/ModelList.java | 21 +- .../client/model/ModelReturn.java | 21 +- .../org/openapitools/client/model/Name.java | 27 +- .../client/model/NullableClass.java | 55 +++- .../openapitools/client/model/NumberOnly.java | 21 +- .../model/ObjectWithDeprecatedFields.java | 29 +- .../org/openapitools/client/model/Order.java | 31 +- .../client/model/OuterComposite.java | 25 +- .../model/OuterObjectWithEnumProperty.java | 21 +- .../org/openapitools/client/model/Pet.java | 34 ++- .../client/model/ReadOnlyFirst.java | 23 +- .../client/model/SpecialModelName.java | 21 +- .../org/openapitools/client/model/Tag.java | 23 +- .../org/openapitools/client/model/User.java | 35 ++- 228 files changed, 8867 insertions(+), 688 deletions(-) create mode 100644 samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md create mode 100644 samples/client/echo_api/java/apache-httpclient/docs/DataQueryAllOf.md create mode 100644 samples/client/echo_api/java/apache-httpclient/docs/Query.md create mode 100644 samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java create mode 100644 samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java create mode 100644 samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java create mode 100644 samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java create mode 100644 samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryTest.java create mode 100644 samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/QueryTest.java create mode 100644 samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java create mode 100644 samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java create mode 100644 samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java create mode 100644 samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java create mode 100644 samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java create mode 100644 samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/QueryTest.java create mode 100644 samples/client/echo_api/java/native/docs/DataQuery.md create mode 100644 samples/client/echo_api/java/native/docs/DataQueryAllOf.md create mode 100644 samples/client/echo_api/java/native/docs/Query.md create mode 100644 samples/client/echo_api/java/native/docs/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.md create mode 100644 samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java create mode 100644 samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java create mode 100644 samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java create mode 100644 samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.java create mode 100644 samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java create mode 100644 samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryTest.java create mode 100644 samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/QueryTest.java create mode 100644 samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameterTest.java create mode 100644 samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md create mode 100644 samples/client/echo_api/java/okhttp-gson/docs/DataQueryAllOf.md create mode 100644 samples/client/echo_api/java/okhttp-gson/docs/Query.md create mode 100644 samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java create mode 100644 samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java create mode 100644 samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java create mode 100644 samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java create mode 100644 samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java create mode 100644 samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/QueryTest.java 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 6dbc623a749..1e97033d626 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 @@ -428,10 +428,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen } // add URL query deepObject support to native, apache-httpclient by default - if (!additionalProperties.containsKey("supportUrlQueryDeepObject") && (isLibrary(NATIVE) || isLibrary(APACHE))) { - additionalProperties.put("supportUrlQueryDeepObject", true); + if (!additionalProperties.containsKey("supportUrlQuery") && (isLibrary(NATIVE) || isLibrary(APACHE))) { + additionalProperties.put("supportUrlQuery", true); } else { - additionalProperties.put("supportUrlQueryDeepObject", Boolean.parseBoolean(additionalProperties.get(SUPPORT_STREAMING).toString())); + additionalProperties.put("supportUrlQuery", Boolean.parseBoolean(additionalProperties.get(SUPPORT_STREAMING).toString())); } final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/"); diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/api.mustache index 9ddfec1d1f8..82466c4a1bc 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/apache-httpclient/api.mustache @@ -76,7 +76,7 @@ public class {{classname}} { String localVarPath = "{{{path}}}"{{#pathParams}} .replaceAll("\\{" + "{{baseName}}" + "\\}", apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}}; - {{javaUtilPrefix}}StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + {{javaUtilPrefix}}StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; {{javaUtilPrefix}}List localVarQueryParams = new {{javaUtilPrefix}}ArrayList(); {{javaUtilPrefix}}List localVarCollectionQueryParams = new {{javaUtilPrefix}}ArrayList(); @@ -89,11 +89,11 @@ public class {{classname}} { localVarQueryParameterBaseName = "{{{baseName}}}"; {{#isArray}} for (int i=0; i < {{paramName}}.size(); i++) { - localVarQueryDeepObjectStringJoiner.add({{paramName}}.get(i).toUrlQueryString(String.format("{{baseName}}[%d]", i))); + localVarQueryStringJoiner.add({{paramName}}.get(i).toUrlQueryString(String.format("{{baseName}}[%d]", i))); } {{/isArray}} {{^isArray}} - localVarQueryDeepObjectStringJoiner.add({{paramName}}.toUrlQueryString("{{baseName}}")); + localVarQueryStringJoiner.add({{paramName}}.toUrlQueryString("{{baseName}}")); {{/isArray}} {{/isDeepObject}} {{^isDeepObject}} @@ -109,7 +109,12 @@ public class {{classname}} { {{/vars}} {{/hasVars}} {{^hasVars}} + {{#isModel}} + localVarQueryStringJoiner.add({{paramName}}.toUrlQueryString()); + {{/isModel}} + {{^isModel}} {{#collectionFormat}}localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("{{{collectionFormat}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(apiClient.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}})); + {{/isModel}} {{/hasVars}} {{/isExplode}} {{^isExplode}} @@ -152,7 +157,7 @@ public class {{classname}} { "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache index 1536a05db62..d0b7dde3c00 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache @@ -338,7 +338,7 @@ public class {{classname}} { {{#hasQueryParams}} {{javaUtilPrefix}}List localVarQueryParams = new {{javaUtilPrefix}}ArrayList<>(); - {{javaUtilPrefix}}StringJoiner localVarQueryDeepObjectStringJoiner = new {{javaUtilPrefix}}StringJoiner("&"); + {{javaUtilPrefix}}StringJoiner localVarQueryStringJoiner = new {{javaUtilPrefix}}StringJoiner("&"); String localVarQueryParameterBaseName; {{#queryParams}} localVarQueryParameterBaseName = "{{{baseName}}}"; @@ -350,11 +350,11 @@ public class {{classname}} { if ({{paramName}} != null) { {{#isArray}} for (int i=0; i < {{paramName}}.size(); i++) { - localVarQueryDeepObjectStringJoiner.add({{paramName}}.get(i).toUrlQueryString(String.format("{{baseName}}[%d]", i))); + localVarQueryStringJoiner.add({{paramName}}.get(i).toUrlQueryString(String.format("{{baseName}}[%d]", i))); } {{/isArray}} {{^isArray}} - localVarQueryDeepObjectStringJoiner.add({{paramName}}.toUrlQueryString("{{baseName}}")); + localVarQueryStringJoiner.add({{paramName}}.toUrlQueryString("{{baseName}}")); {{/isArray}} } {{/isDeepObject}} @@ -371,7 +371,12 @@ public class {{classname}} { {{/vars}} {{/hasVars}} {{^hasVars}} + {{#isModel}} + localVarQueryStringJoiner.add({{paramName}}.toUrlQueryString(null)); + {{/isModel}} + {{^isModel}} localVarQueryParams.addAll(ApiClient.parameterToPairs("{{baseName}}", {{paramName}})); + {{/isModel}} {{/hasVars}} {{/isExplode}} {{^isExplode}} @@ -381,11 +386,11 @@ public class {{classname}} { {{/collectionFormat}} {{/queryParams}} - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { {{javaUtilPrefix}}StringJoiner queryJoiner = new {{javaUtilPrefix}}StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/model.mustache index 0bab3ea7919..40d8a5a4065 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/model.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/model.mustache @@ -16,11 +16,11 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; {{/additionalPropertiesType}} {{/model}} {{/models}} -{{#supportUrlQueryDeepObject}} +{{#supportUrlQuery}} import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.StringJoiner; -{{/supportUrlQueryDeepObject}} +{{/supportUrlQuery}} import java.util.Objects; import java.util.Arrays; import java.util.Map; diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/modelEnum.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/modelEnum.mustache index 8126b906b1b..b4cd2f4109f 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/modelEnum.mustache @@ -62,7 +62,7 @@ import com.google.gson.stream.JsonWriter; } {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}} } -{{#supportUrlQueryDeepObject}} +{{#supportUrlQuery}} /** * Convert the instance into URL query string. @@ -77,7 +77,7 @@ import com.google.gson.stream.JsonWriter; return String.format("%s=%s", prefix, this.toString()); } -{{/supportUrlQueryDeepObject}} +{{/supportUrlQuery}} {{#gson}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache index 62f88ec74e3..79c5e846113 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/native/pojo.mustache @@ -348,7 +348,16 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens } return o.toString().replace("\n", "\n "); } -{{#supportUrlQueryDeepObject}} +{{#supportUrlQuery}} + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } /** * Convert the instance into URL query string. @@ -357,8 +366,18 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -371,7 +390,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { int i = 0; for ({{items.dataType}} _item : {{getter}}()) { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } i++; } @@ -379,7 +400,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{^uniqueItems}} if ({{getter}}() != null) { for (int i = 0; i < {{getter}}().size(); i++) { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf({{getter}}().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf({{getter}}().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } {{/uniqueItems}} @@ -391,7 +414,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens int i = 0; for ({{items.dataType}} _item : {{getter}}()) { if ({{getter}}().get(i) != null) { - joiner.add(_item.toUrlQueryString(String.format("%s[{{baseName}}][%d]", prefix, i))); + joiner.add(_item.toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } i++; @@ -401,7 +425,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { for (int i = 0; i < {{getter}}().size(); i++) { if ({{getter}}().get(i) != null) { - joiner.add({{getter}}().get(i).toUrlQueryString(String.format("%s[{{baseName}}][%d]", prefix, i))); + joiner.add({{getter}}().get(i).toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -413,7 +438,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens int i = 0; for ({{items.dataType}} _item : {{getter}}()) { if (_item != null) { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)), + URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20")); } i++; } @@ -423,7 +450,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { for (int i = 0; i < {{getter}}().size(); i++) { if ({{getter}}().get(i) != null) { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf({{getter}}().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf({{getter}}().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } } @@ -436,7 +465,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{#items.isPrimitiveType}} if ({{getter}}() != null) { for (String _key : {{getter}}().keySet()) { - joiner.add(String.format("%s[{{baseName}}][%s]=%s", prefix, {{getter}}().get(_key), URLEncoder.encode(String.valueOf({{getter}}().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + {{getter}}().get(_key), URLEncoder.encode(String.valueOf({{getter}}().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } {{/items.isPrimitiveType}} @@ -444,7 +475,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { for (String _key : {{getter}}().keySet()) { if ({{getter}}().get(_key) != null) { - joiner.add({{getter}}().get(_key).toUrlQueryString(String.format("%s[{{baseName}}][%s]", prefix, _key))); + joiner.add({{getter}}().get(_key).toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); } } } @@ -453,18 +485,18 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{^isMap}} {{#isPrimitiveType}} if ({{getter}}() != null) { - joiner.add(String.format("%s[{{{baseName}}}]=%s", prefix, URLEncoder.encode(String.valueOf({{{getter}}}()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{{baseName}}}%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf({{{getter}}}()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isModel}} if ({{getter}}() != null) { - joiner.add({{getter}}().toUrlQueryString(prefix + "[{{{baseName}}}]")); + joiner.add({{getter}}().toUrlQueryString(prefix + "{{{baseName}}}" + suffix)); } {{/isModel}} {{^isModel}} if ({{getter}}() != null) { - joiner.add(String.format("%s[{{{baseName}}}]=%s", prefix, URLEncoder.encode(String.valueOf({{{getter}}}()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{{baseName}}}%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf({{{getter}}}()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } {{/isModel}} {{/isPrimitiveType}} @@ -474,7 +506,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{/allVars}} return joiner.toString(); } -{{/supportUrlQueryDeepObject}} +{{/supportUrlQuery}} {{#parcelableModel}} public void writeToParcel(Parcel out, int flags) { diff --git a/modules/openapi-generator/src/main/resources/Java/model.mustache b/modules/openapi-generator/src/main/resources/Java/model.mustache index 361718411ad..55e6678d2f0 100644 --- a/modules/openapi-generator/src/main/resources/Java/model.mustache +++ b/modules/openapi-generator/src/main/resources/Java/model.mustache @@ -55,11 +55,11 @@ import {{javaxPackage}}.validation.Valid; {{#performBeanValidation}} import org.hibernate.validator.constraints.*; {{/performBeanValidation}} -{{#supportUrlQueryDeepObject}} +{{#supportUrlQuery}} import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.StringJoiner; -{{/supportUrlQueryDeepObject}} +{{/supportUrlQuery}} {{#models}} {{#model}} diff --git a/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache b/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache index cad11e343c4..1d3832d06ba 100644 --- a/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache +++ b/modules/openapi-generator/src/main/resources/Java/modelEnum.mustache @@ -98,7 +98,7 @@ import com.google.gson.stream.JsonWriter; } } {{/jsonb}} -{{#supportUrlQueryDeepObject}} +{{#supportUrlQuery}} /** * Convert the instance into URL query string. @@ -113,5 +113,5 @@ import com.google.gson.stream.JsonWriter; return String.format("%s=%s", prefix, this.toString()); } -{{/supportUrlQueryDeepObject}} +{{/supportUrlQuery}} } diff --git a/modules/openapi-generator/src/main/resources/Java/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/pojo.mustache index f7bf0dc2965..057c62d6623 100644 --- a/modules/openapi-generator/src/main/resources/Java/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/Java/pojo.mustache @@ -336,7 +336,16 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens } return o.toString().replace("\n", "\n "); } -{{#supportUrlQueryDeepObject}} +{{#supportUrlQuery}} + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } /** * Convert the instance into URL query string. @@ -345,10 +354,22 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + {{#allVars}} // add `{{baseName}}` to the URL query string {{#isArray}} @@ -358,7 +379,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens int i = 0; for ({{items.dataType}} _item : {{getter}}()) { try { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -371,7 +394,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { for (int i = 0; i < {{getter}}().size(); i++) { try { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf({{getter}}().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf({{getter}}().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -387,7 +412,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens int i = 0; for ({{items.dataType}} _item : {{getter}}()) { if ({{getter}}().get(i) != null) { - joiner.add(_item.toUrlQueryString(String.format("%s[{{baseName}}][%d]", prefix, i))); + joiner.add(_item.toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } i++; @@ -397,7 +423,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { for (int i = 0; i < {{getter}}().size(); i++) { if ({{getter}}().get(i) != null) { - joiner.add({{getter}}().get(i).toUrlQueryString(String.format("%s[{{baseName}}][%d]", prefix, i))); + joiner.add({{getter}}().get(i).toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } @@ -410,7 +437,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens for ({{items.dataType}} _item : {{getter}}()) { if (_item != null) { try { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)), + URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20")); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -425,7 +454,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens for (int i = 0; i < {{getter}}().size(); i++) { if ({{getter}}().get(i) != null) { try { - joiner.add(String.format("%s[{{baseName}}][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf({{getter}}().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf({{getter}}().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -443,7 +474,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { for (String _key : {{getter}}().keySet()) { try { - joiner.add(String.format("%s[{{baseName}}][%s]=%s", prefix, {{getter}}().get(_key), URLEncoder.encode(String.valueOf({{getter}}().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{baseName}}%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + {{getter}}().get(_key), URLEncoder.encode(String.valueOf({{getter}}().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -455,7 +488,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens if ({{getter}}() != null) { for (String _key : {{getter}}().keySet()) { if ({{getter}}().get(_key) != null) { - joiner.add({{getter}}().get(_key).toUrlQueryString(String.format("%s[{{baseName}}][%s]", prefix, _key))); + joiner.add({{getter}}().get(_key).toUrlQueryString(String.format("%s{{baseName}}%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); } } } @@ -465,7 +499,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{#isPrimitiveType}} if ({{getter}}() != null) { try { - joiner.add(String.format("%s[{{{baseName}}}]=%s", prefix, URLEncoder.encode(String.valueOf({{{getter}}}()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{{baseName}}}%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf({{{getter}}}()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -475,13 +509,13 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{^isPrimitiveType}} {{#isModel}} if ({{getter}}() != null) { - joiner.add({{getter}}().toUrlQueryString(prefix + "[{{{baseName}}}]")); + joiner.add({{getter}}().toUrlQueryString(prefix + "{{{baseName}}}" + suffix)); } {{/isModel}} {{^isModel}} if ({{getter}}() != null) { try { - joiner.add(String.format("%s[{{{baseName}}}]=%s", prefix, URLEncoder.encode(String.valueOf({{{getter}}}()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s{{{baseName}}}%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf({{{getter}}}()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -491,10 +525,11 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens {{/isPrimitiveType}} {{/isMap}} {{/isArray}} + {{/allVars}} return joiner.toString(); } -{{/supportUrlQueryDeepObject}} +{{/supportUrlQuery}} {{#parcelableModel}} public void writeToParcel(Parcel out, int flags) { diff --git a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml index 4008a3775c1..82bfa963c10 100644 --- a/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/echo_api.yaml @@ -137,6 +137,27 @@ paths: text/plain: schema: type: string + /query/style_form/explode_true/object/allOf: + get: + tags: + - query + summary: Test query parameter(s) + description: Test query parameter(s) + operationId: test/query/style_form/explode_true/object/allOf + parameters: + - in: query + name: query_object + style: form #default + explode: true #default + schema: + $ref: '#/components/schemas/DataQuery' + responses: + '200': + description: Successful operation + content: + text/plain: + schema: + type: string /query/style_deepObject/explode_true/object: get: tags: @@ -274,3 +295,38 @@ components: type: string color: type: string + Query: + type: object + x-parent: true + properties: + id: + type: integer + description: Query + format: int64 + outcomes: + type: array + items: + type: string + enum: + - SUCCESS + - FAILURE + - SKIPPED + default: + - SUCCESS + - FAILURE + DataQuery: + allOf: + - type: object + properties: + suffix: + type: string + description: test suffix + text: + type: string + description: Some text containing white spaces + example: "Some text" + date: + type: string + format: date-time + description: A date + - $ref: '#/components/schemas/Query' diff --git a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES index 4959dca8d25..211be50eebe 100644 --- a/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES +++ b/samples/client/echo_api/java/apache-httpclient/.openapi-generator/FILES @@ -8,8 +8,11 @@ build.sbt docs/Bird.md docs/BodyApi.md docs/Category.md +docs/DataQuery.md +docs/DataQueryAllOf.md docs/PathApi.md docs/Pet.md +docs/Query.md docs/QueryApi.md docs/Tag.md docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md @@ -41,7 +44,10 @@ src/main/java/org/openapitools/client/auth/HttpBasicAuth.java src/main/java/org/openapitools/client/auth/HttpBearerAuth.java src/main/java/org/openapitools/client/model/Bird.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/DataQuery.java +src/main/java/org/openapitools/client/model/DataQueryAllOf.java src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Query.java src/main/java/org/openapitools/client/model/Tag.java src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java diff --git a/samples/client/echo_api/java/apache-httpclient/README.md b/samples/client/echo_api/java/apache-httpclient/README.md index 566da595f10..2b9dc39df25 100644 --- a/samples/client/echo_api/java/apache-httpclient/README.md +++ b/samples/client/echo_api/java/apache-httpclient/README.md @@ -113,13 +113,17 @@ Class | Method | HTTP request | Description *QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObjectAllOf**](docs/QueryApi.md#testQueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) *QueryApi* | [**testQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#testQueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) *QueryApi* | [**testQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) +*QueryApi* | [**testQueryStyleFormExplodeTrueObjectAllOf**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) ## Documentation for Models - [Bird](docs/Bird.md) - [Category](docs/Category.md) + - [DataQuery](docs/DataQuery.md) + - [DataQueryAllOf](docs/DataQueryAllOf.md) - [Pet](docs/Pet.md) + - [Query](docs/Query.md) - [Tag](docs/Tag.md) - [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md) - [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md) diff --git a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml index 93bbf6fbd08..3fc6ac3d6c8 100644 --- a/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml +++ b/samples/client/echo_api/java/apache-httpclient/api/openapi.yaml @@ -124,6 +124,29 @@ paths: tags: - query x-accepts: text/plain + /query/style_form/explode_true/object/allOf: + get: + description: Test query parameter(s) + operationId: test/query/style_form/explode_true/object/allOf + parameters: + - explode: true + in: query + name: query_object + required: false + schema: + $ref: '#/components/schemas/DataQuery' + style: form + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test query parameter(s) + tags: + - query + x-accepts: text/plain /query/style_deepObject/explode_true/object: get: description: Test query parameter(s) @@ -285,6 +308,29 @@ components: color: type: string type: object + Query: + properties: + id: + description: Query + format: int64 + type: integer + outcomes: + default: + - SUCCESS + - FAILURE + items: + enum: + - SUCCESS + - FAILURE + - SKIPPED + type: string + type: array + type: object + x-parent: true + DataQuery: + allOf: + - $ref: '#/components/schemas/DataQuery_allOf' + - $ref: '#/components/schemas/Query' test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: @@ -296,4 +342,19 @@ components: allOf: - $ref: '#/components/schemas/Bird' - $ref: '#/components/schemas/Category' + DataQuery_allOf: + properties: + suffix: + description: test suffix + type: string + text: + description: Some text containing white spaces + example: Some text + type: string + date: + description: A date + format: date-time + type: string + type: object + example: null diff --git a/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md b/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md new file mode 100644 index 00000000000..338c467b2d5 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/docs/DataQuery.md @@ -0,0 +1,15 @@ + + +# DataQuery + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**suffix** | **String** | test suffix | [optional] | +|**text** | **String** | Some text containing white spaces | [optional] | +|**date** | **OffsetDateTime** | A date | [optional] | + + + diff --git a/samples/client/echo_api/java/apache-httpclient/docs/DataQueryAllOf.md b/samples/client/echo_api/java/apache-httpclient/docs/DataQueryAllOf.md new file mode 100644 index 00000000000..cc8aa2952e9 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/docs/DataQueryAllOf.md @@ -0,0 +1,15 @@ + + +# DataQueryAllOf + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**suffix** | **String** | test suffix | [optional] | +|**text** | **String** | Some text containing white spaces | [optional] | +|**date** | **OffsetDateTime** | A date | [optional] | + + + diff --git a/samples/client/echo_api/java/apache-httpclient/docs/Query.md b/samples/client/echo_api/java/apache-httpclient/docs/Query.md new file mode 100644 index 00000000000..99c6fd6faa5 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/docs/Query.md @@ -0,0 +1,24 @@ + + +# Query + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | Query | [optional] | +|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | + + + +## Enum: List<OutcomesEnum> + +| Name | Value | +|---- | -----| +| SUCCESS | "SUCCESS" | +| FAILURE | "FAILURE" | +| SKIPPED | "SKIPPED" | + + + diff --git a/samples/client/echo_api/java/apache-httpclient/docs/QueryApi.md b/samples/client/echo_api/java/apache-httpclient/docs/QueryApi.md index 58098fb7318..9f93285fdb2 100644 --- a/samples/client/echo_api/java/apache-httpclient/docs/QueryApi.md +++ b/samples/client/echo_api/java/apache-httpclient/docs/QueryApi.md @@ -9,6 +9,7 @@ All URIs are relative to *http://localhost:3000* | [**testQueryStyleDeepObjectExplodeTrueObjectAllOf**](QueryApi.md#testQueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) | | [**testQueryStyleFormExplodeTrueArrayString**](QueryApi.md#testQueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) | | [**testQueryStyleFormExplodeTrueObject**](QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) | +| [**testQueryStyleFormExplodeTrueObjectAllOf**](QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) | @@ -345,3 +346,69 @@ No authorization required |-------------|-------------|------------------| | **200** | Successful operation | - | + +## testQueryStyleFormExplodeTrueObjectAllOf + +> String testQueryStyleFormExplodeTrueObjectAllOf(queryObject) + +Test query parameter(s) + +Test query parameter(s) + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.QueryApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + QueryApi apiInstance = new QueryApi(defaultClient); + DataQuery queryObject = new DataQuery(); // DataQuery | + try { + String result = apiInstance.testQueryStyleFormExplodeTrueObjectAllOf(queryObject); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling QueryApi#testQueryStyleFormExplodeTrueObjectAllOf"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **queryObject** | [**DataQuery**](.md)| | [optional] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/plain + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java index ae7794aa0d0..faa75d6477c 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/BodyApi.java @@ -62,7 +62,7 @@ public class BodyApi { // create path and map variables String localVarPath = "/echo/body/Pet"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -91,7 +91,7 @@ public class BodyApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/PathApi.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/PathApi.java index 5b1cb23d5ae..6f3e8b5fcfa 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/PathApi.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/PathApi.java @@ -74,7 +74,7 @@ public class PathApi { .replaceAll("\\{" + "path_string" + "\\}", apiClient.escapeString(pathString.toString())) .replaceAll("\\{" + "path_integer" + "\\}", apiClient.escapeString(pathInteger.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -103,7 +103,7 @@ public class PathApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/QueryApi.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/QueryApi.java index 836f0c3111a..8328ee09d62 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/QueryApi.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/api/QueryApi.java @@ -20,6 +20,7 @@ import org.openapitools.client.Configuration; import org.openapitools.client.model.*; import org.openapitools.client.Pair; +import org.openapitools.client.model.DataQuery; import org.openapitools.client.model.Pet; import org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter; import org.openapitools.client.model.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter; @@ -66,7 +67,7 @@ public class QueryApi { // create path and map variables String localVarPath = "/query/integer/boolean/string"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -98,7 +99,7 @@ public class QueryApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -122,7 +123,7 @@ public class QueryApi { // create path and map variables String localVarPath = "/query/style_deepObject/explode_true/object"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -131,7 +132,7 @@ public class QueryApi { Map localVarFormParams = new HashMap(); localVarQueryParameterBaseName = "query_object"; - localVarQueryDeepObjectStringJoiner.add(queryObject.toUrlQueryString("query_object")); + localVarQueryStringJoiner.add(queryObject.toUrlQueryString("query_object")); @@ -153,7 +154,7 @@ public class QueryApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -177,7 +178,7 @@ public class QueryApi { // create path and map variables String localVarPath = "/query/style_deepObject/explode_true/object/allOf"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -186,7 +187,7 @@ public class QueryApi { Map localVarFormParams = new HashMap(); localVarQueryParameterBaseName = "query_object"; - localVarQueryDeepObjectStringJoiner.add(queryObject.toUrlQueryString("query_object")); + localVarQueryStringJoiner.add(queryObject.toUrlQueryString("query_object")); @@ -208,7 +209,7 @@ public class QueryApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -232,7 +233,7 @@ public class QueryApi { // create path and map variables String localVarPath = "/query/style_form/explode_true/array_string"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -262,7 +263,7 @@ public class QueryApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -286,7 +287,7 @@ public class QueryApi { // create path and map variables String localVarPath = "/query/style_form/explode_true/object"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -321,7 +322,61 @@ public class QueryApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAccept, + localVarContentType, + localVarAuthNames, + localVarReturnType + ); + } + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleFormExplodeTrueObjectAllOf(DataQuery queryObject) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/query/style_form/explode_true/object/allOf"; + + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + localVarQueryStringJoiner.add(queryObject.toUrlQueryString()); + + + + final String[] localVarAccepts = { + "text/plain" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + TypeReference localVarReturnType = new TypeReference() {}; + return apiClient.invokeAPI( + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java index 1c04169e74e..a42433b9d5c 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Bird.java @@ -135,6 +135,15 @@ public class Bird { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -142,28 +151,42 @@ public class Bird { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `size` to the URL query string if (getSize() != null) { try { - joiner.add(String.format("%s[size]=%s", prefix, URLEncoder.encode(String.valueOf(getSize()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `color` to the URL query string if (getColor() != null) { try { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java index 83a32b0e607..9d205aa629e 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java @@ -135,6 +135,15 @@ public class Category { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -142,28 +151,42 @@ public class Category { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java new file mode 100644 index 00000000000..482cc9c3246 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQuery.java @@ -0,0 +1,267 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; + +/** + * DataQuery + */ +@JsonPropertyOrder({ + DataQuery.JSON_PROPERTY_SUFFIX, + DataQuery.JSON_PROPERTY_TEXT, + DataQuery.JSON_PROPERTY_DATE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { + public static final String JSON_PROPERTY_SUFFIX = "suffix"; + private String suffix; + + public static final String JSON_PROPERTY_TEXT = "text"; + private String text; + + public static final String JSON_PROPERTY_DATE = "date"; + private OffsetDateTime date; + + public DataQuery() { + + } + + public DataQuery suffix(String suffix) { + + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSuffix() { + return suffix; + } + + + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQuery text(String text) { + + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getText() { + return text; + } + + + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setText(String text) { + this.text = text; + } + + + public DataQuery date(OffsetDateTime date) { + + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public OffsetDateTime getDate() { + return date; + } + + + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQuery dataQuery = (DataQuery) o; + return Objects.equals(this.suffix, dataQuery.suffix) && + Objects.equals(this.text, dataQuery.text) && + Objects.equals(this.date, dataQuery.date) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `suffix` to the URL query string + if (getSuffix() != null) { + try { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `text` to the URL query string + if (getText() != null) { + try { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `date` to the URL query string + if (getDate() != null) { + try { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `id` to the URL query string + if (getId() != null) { + try { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `outcomes` to the URL query string + if (getOutcomes() != null) { + for (int i = 0; i < getOutcomes().size(); i++) { + try { + joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getOutcomes().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + return joiner.toString(); + } + +} + diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java new file mode 100644 index 00000000000..971198bc355 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -0,0 +1,238 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; + +/** + * DataQueryAllOf + */ +@JsonPropertyOrder({ + DataQueryAllOf.JSON_PROPERTY_SUFFIX, + DataQueryAllOf.JSON_PROPERTY_TEXT, + DataQueryAllOf.JSON_PROPERTY_DATE +}) +@JsonTypeName("DataQuery_allOf") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQueryAllOf { + public static final String JSON_PROPERTY_SUFFIX = "suffix"; + private String suffix; + + public static final String JSON_PROPERTY_TEXT = "text"; + private String text; + + public static final String JSON_PROPERTY_DATE = "date"; + private OffsetDateTime date; + + public DataQueryAllOf() { + } + + public DataQueryAllOf suffix(String suffix) { + + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSuffix() { + return suffix; + } + + + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQueryAllOf text(String text) { + + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getText() { + return text; + } + + + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setText(String text) { + this.text = text; + } + + + public DataQueryAllOf date(OffsetDateTime date) { + + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public OffsetDateTime getDate() { + return date; + } + + + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQueryAllOf dataQueryAllOf = (DataQueryAllOf) o; + return Objects.equals(this.suffix, dataQueryAllOf.suffix) && + Objects.equals(this.text, dataQueryAllOf.text) && + Objects.equals(this.date, dataQueryAllOf.date); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQueryAllOf {\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `suffix` to the URL query string + if (getSuffix() != null) { + try { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `text` to the URL query string + if (getText() != null) { + try { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `date` to the URL query string + if (getDate() != null) { + try { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + return joiner.toString(); + } + +} + diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java index c8d31ad5203..dbdb5ed4472 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java @@ -317,6 +317,15 @@ public class Pet { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -324,60 +333,81 @@ public class Pet { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `category` to the URL query string if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "[category]")); + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); } + // add `photoUrls` to the URL query string if (getPhotoUrls() != null) { for (int i = 0; i < getPhotoUrls().size(); i++) { try { - joiner.add(String.format("%s[photoUrls][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `tags` to the URL query string if (getTags() != null) { for (int i = 0; i < getTags().size(); i++) { if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%s[tags][%d]", prefix, i))); + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } + // add `status` to the URL query string if (getStatus() != null) { try { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java new file mode 100644 index 00000000000..69afb02eb4c --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Query.java @@ -0,0 +1,245 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.StringJoiner; + +/** + * Query + */ +@JsonPropertyOrder({ + Query.JSON_PROPERTY_ID, + Query.JSON_PROPERTY_OUTCOMES +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Query { + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + /** + * Gets or Sets outcomes + */ + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; + private List outcomes = null; + + public Query() { + } + + public Query id(Long id) { + + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(Long id) { + this.id = id; + } + + + public Query outcomes(List outcomes) { + + this.outcomes = outcomes; + return this; + } + + public Query addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public List getOutcomes() { + return outcomes; + } + + + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Query query = (Query) o; + return Objects.equals(this.id, query.id) && + Objects.equals(this.outcomes, query.outcomes); + } + + @Override + public int hashCode() { + return Objects.hash(id, outcomes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Query {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + try { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `outcomes` to the URL query string + if (getOutcomes() != null) { + for (int i = 0; i < getOutcomes().size(); i++) { + try { + joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getOutcomes().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + return joiner.toString(); + } + +} + diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java index b25c5ee7edd..7692d8a1fc4 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java @@ -135,6 +135,15 @@ public class Tag { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -142,28 +151,42 @@ public class Tag { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java index 75c2a6bb74b..73f67121d01 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java @@ -200,6 +200,15 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -207,46 +216,62 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `size` to the URL query string if (getSize() != null) { try { - joiner.add(String.format("%s[size]=%s", prefix, URLEncoder.encode(String.valueOf(getSize()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `color` to the URL query string if (getColor() != null) { try { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java index 24a20a9f2c7..c62cd859c36 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java +++ b/samples/client/echo_api/java/apache-httpclient/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java @@ -114,6 +114,15 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -121,21 +130,36 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `values` to the URL query string if (getValues() != null) { for (int i = 0; i < getValues().size(); i++) { try { - joiner.add(String.format("%s[values][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getValues().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%svalues%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getValues().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + return joiner.toString(); } diff --git a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java index 643926e6b42..b76e3601e32 100644 --- a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java +++ b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/CustomTest.java @@ -89,6 +89,24 @@ public class CustomTest { Assert.assertEquals("/query/style_deepObject/explode_true/object?query_object[id]=12345&query_object[name]=Hello%20World&query_object[category][id]=987&query_object[category][name]=new%20category&query_object[photoUrls][0]=http%3A%2F%2Fa.com&query_object[photoUrls][1]=http%3A%2F%2Fb.com", p.path); } + /** + * Test query parameter(s) + *

+ * Test query parameter(s) + * + * @throws ApiException if the Api call fails + */ + @Test + public void testQueryStyleFormExplodeTrueObjectAllOfTest() throws ApiException { + DataQuery queryObject = new DataQuery().text("Hello World"); + queryObject.setId(3487L); + queryObject.setOutcomes(Arrays.asList(Query.OutcomesEnum.SKIPPED, Query.OutcomesEnum.FAILURE)); + + String response = api.testQueryStyleFormExplodeTrueObjectAllOf(queryObject); + org.openapitools.client.EchoServerResponseParser p = new org.openapitools.client.EchoServerResponseParser(response); + Assert.assertEquals("/query/style_form/explode_true/object/allOf?text=Hello%20World&id=3487&outcomes=SKIPPED&outcomes=FAILURE", p.path); + } + /** * Test query parameter(s) *

diff --git a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java new file mode 100644 index 00000000000..8a1afad2563 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java @@ -0,0 +1,57 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for DataQueryAllOf + */ +public class DataQueryAllOfTest { + private final DataQueryAllOf model = new DataQueryAllOf(); + + /** + * Model tests for DataQueryAllOf + */ + @Test + public void testDataQueryAllOf() { + // TODO: test DataQueryAllOf + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + public void dateTest() { + // TODO: test date + } + +} diff --git a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryTest.java b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryTest.java new file mode 100644 index 00000000000..9b71c406586 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/DataQueryTest.java @@ -0,0 +1,76 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for DataQuery + */ +public class DataQueryTest { + private final DataQuery model = new DataQuery(); + + /** + * Model tests for DataQuery + */ + @Test + public void testDataQuery() { + // TODO: test DataQuery + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + public void dateTest() { + // TODO: test date + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + public void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/QueryTest.java b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/QueryTest.java new file mode 100644 index 00000000000..266a3cb6739 --- /dev/null +++ b/samples/client/echo_api/java/apache-httpclient/src/test/java/org/openapitools/client/model/QueryTest.java @@ -0,0 +1,58 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for Query + */ +public class QueryTest { + private final Query model = new Query(); + + /** + * Model tests for Query + */ + @Test + public void testQuery() { + // TODO: test Query + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + public void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES b/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES index be65be612a2..7a45316b566 100644 --- a/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES +++ b/samples/client/echo_api/java/feign-gson/.openapi-generator/FILES @@ -28,7 +28,10 @@ src/main/java/org/openapitools/client/auth/HttpBearerAuth.java src/main/java/org/openapitools/client/model/ApiResponse.java src/main/java/org/openapitools/client/model/Bird.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/DataQuery.java +src/main/java/org/openapitools/client/model/DataQueryAllOf.java src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Query.java src/main/java/org/openapitools/client/model/Tag.java src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java diff --git a/samples/client/echo_api/java/feign-gson/api/openapi.yaml b/samples/client/echo_api/java/feign-gson/api/openapi.yaml index 93bbf6fbd08..3fc6ac3d6c8 100644 --- a/samples/client/echo_api/java/feign-gson/api/openapi.yaml +++ b/samples/client/echo_api/java/feign-gson/api/openapi.yaml @@ -124,6 +124,29 @@ paths: tags: - query x-accepts: text/plain + /query/style_form/explode_true/object/allOf: + get: + description: Test query parameter(s) + operationId: test/query/style_form/explode_true/object/allOf + parameters: + - explode: true + in: query + name: query_object + required: false + schema: + $ref: '#/components/schemas/DataQuery' + style: form + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test query parameter(s) + tags: + - query + x-accepts: text/plain /query/style_deepObject/explode_true/object: get: description: Test query parameter(s) @@ -285,6 +308,29 @@ components: color: type: string type: object + Query: + properties: + id: + description: Query + format: int64 + type: integer + outcomes: + default: + - SUCCESS + - FAILURE + items: + enum: + - SUCCESS + - FAILURE + - SKIPPED + type: string + type: array + type: object + x-parent: true + DataQuery: + allOf: + - $ref: '#/components/schemas/DataQuery_allOf' + - $ref: '#/components/schemas/Query' test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: @@ -296,4 +342,19 @@ components: allOf: - $ref: '#/components/schemas/Bird' - $ref: '#/components/schemas/Category' + DataQuery_allOf: + properties: + suffix: + description: test suffix + type: string + text: + description: Some text containing white spaces + example: Some text + type: string + date: + description: A date + format: date-time + type: string + type: object + example: null diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/QueryApi.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/QueryApi.java index b41bd4ad40a..fafd87f6859 100644 --- a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/QueryApi.java +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/api/QueryApi.java @@ -4,6 +4,7 @@ import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; import org.openapitools.client.model.ApiResponse; +import org.openapitools.client.model.DataQuery; import org.openapitools.client.model.Pet; import org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter; import org.openapitools.client.model.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter; @@ -418,4 +419,81 @@ public interface QueryApi extends ApiClient.Api { return this; } } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @return String + */ + @RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}") + @Headers({ + "Accept: text/plain", + }) + String testQueryStyleFormExplodeTrueObjectAllOf(@Param("queryObject") DataQuery queryObject); + + /** + * Test query parameter(s) + * Similar to testQueryStyleFormExplodeTrueObjectAllOf but it also returns the http response headers . + * Test query parameter(s) + * @param queryObject (optional) + * @return A ApiResponse that wraps the response boyd and the http headers. + */ + @RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}") + @Headers({ + "Accept: text/plain", + }) + ApiResponse testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(@Param("queryObject") DataQuery queryObject); + + + /** + * Test query parameter(s) + * Test query parameter(s) + * Note, this is equivalent to the other testQueryStyleFormExplodeTrueObjectAllOf method, + * but with the query parameters collected into a single Map parameter. This + * is convenient for services with optional query parameters, especially when + * used with the {@link TestQueryStyleFormExplodeTrueObjectAllOfQueryParams} class that allows for + * building up this map in a fluent style. + * @param queryParams Map of query parameters as name-value pairs + *

The following elements may be specified in the query map:

+ *
    + *
  • queryObject - (optional)
  • + *
+ * @return String + */ + @RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}") + @Headers({ + "Accept: text/plain", + }) + String testQueryStyleFormExplodeTrueObjectAllOf(@QueryMap(encoded=true) TestQueryStyleFormExplodeTrueObjectAllOfQueryParams queryParams); + + /** + * Test query parameter(s) + * Test query parameter(s) + * Note, this is equivalent to the other testQueryStyleFormExplodeTrueObjectAllOf that receives the query parameters as a map, + * but this one also exposes the Http response headers + * @param queryParams Map of query parameters as name-value pairs + *

The following elements may be specified in the query map:

+ *
    + *
  • queryObject - (optional)
  • + *
+ * @return String + */ + @RequestLine("GET /query/style_form/explode_true/object/allOf?query_object={queryObject}") + @Headers({ + "Accept: text/plain", + }) + ApiResponse testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(@QueryMap(encoded=true) TestQueryStyleFormExplodeTrueObjectAllOfQueryParams queryParams); + + + /** + * A convenience class for generating query parameters for the + * testQueryStyleFormExplodeTrueObjectAllOf method in a fluent style. + */ + public static class TestQueryStyleFormExplodeTrueObjectAllOfQueryParams extends HashMap { + public TestQueryStyleFormExplodeTrueObjectAllOfQueryParams queryObject(final DataQuery value) { + put("query_object", EncodingUtils.encode(value)); + return this; + } + } } diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java new file mode 100644 index 00000000000..1e0355bab78 --- /dev/null +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQuery.java @@ -0,0 +1,160 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; + +/** + * DataQuery + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { + public static final String SERIALIZED_NAME_SUFFIX = "suffix"; + @SerializedName(SERIALIZED_NAME_SUFFIX) + private String suffix; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + private String text; + + public static final String SERIALIZED_NAME_DATE = "date"; + @SerializedName(SERIALIZED_NAME_DATE) + private OffsetDateTime date; + + public DataQuery() { + + } + + public DataQuery suffix(String suffix) { + + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + + public String getSuffix() { + return suffix; + } + + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQuery text(String text) { + + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + + public String getText() { + return text; + } + + + public void setText(String text) { + this.text = text; + } + + + public DataQuery date(OffsetDateTime date) { + + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + + public OffsetDateTime getDate() { + return date; + } + + + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQuery dataQuery = (DataQuery) o; + return Objects.equals(this.suffix, dataQuery.suffix) && + Objects.equals(this.text, dataQuery.text) && + Objects.equals(this.date, dataQuery.date) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java new file mode 100644 index 00000000000..08b9865487c --- /dev/null +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -0,0 +1,154 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * DataQueryAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQueryAllOf { + public static final String SERIALIZED_NAME_SUFFIX = "suffix"; + @SerializedName(SERIALIZED_NAME_SUFFIX) + private String suffix; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + private String text; + + public static final String SERIALIZED_NAME_DATE = "date"; + @SerializedName(SERIALIZED_NAME_DATE) + private OffsetDateTime date; + + public DataQueryAllOf() { + } + + public DataQueryAllOf suffix(String suffix) { + + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + + public String getSuffix() { + return suffix; + } + + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQueryAllOf text(String text) { + + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + + public String getText() { + return text; + } + + + public void setText(String text) { + this.text = text; + } + + + public DataQueryAllOf date(OffsetDateTime date) { + + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + + public OffsetDateTime getDate() { + return date; + } + + + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQueryAllOf dataQueryAllOf = (DataQueryAllOf) o; + return Objects.equals(this.suffix, dataQueryAllOf.suffix) && + Objects.equals(this.text, dataQueryAllOf.text) && + Objects.equals(this.date, dataQueryAllOf.date); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQueryAllOf {\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java new file mode 100644 index 00000000000..ee7c8929fe7 --- /dev/null +++ b/samples/client/echo_api/java/feign-gson/src/main/java/org/openapitools/client/model/Query.java @@ -0,0 +1,184 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Query + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Query { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private Long id; + + /** + * Gets or Sets outcomes + */ + @JsonAdapter(OutcomesEnum.Adapter.class) + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OutcomesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public OutcomesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return OutcomesEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_OUTCOMES = "outcomes"; + @SerializedName(SERIALIZED_NAME_OUTCOMES) + private List outcomes = null; + + public Query() { + } + + public Query id(Long id) { + + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @javax.annotation.Nullable + + public Long getId() { + return id; + } + + + public void setId(Long id) { + this.id = id; + } + + + public Query outcomes(List outcomes) { + + this.outcomes = outcomes; + return this; + } + + public Query addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @javax.annotation.Nullable + + public List getOutcomes() { + return outcomes; + } + + + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Query query = (Query) o; + return Objects.equals(this.id, query.id) && + Objects.equals(this.outcomes, query.outcomes); + } + + @Override + public int hashCode() { + return Objects.hash(id, outcomes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Query {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java new file mode 100644 index 00000000000..b782d973aba --- /dev/null +++ b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java @@ -0,0 +1,56 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for DataQueryAllOf + */ +class DataQueryAllOfTest { + private final DataQueryAllOf model = new DataQueryAllOf(); + + /** + * Model tests for DataQueryAllOf + */ + @Test + void testDataQueryAllOf() { + // TODO: test DataQueryAllOf + } + + /** + * Test the property 'text' + */ + @Test + void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + void dateTest() { + // TODO: test date + } + +} diff --git a/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java new file mode 100644 index 00000000000..e5178841791 --- /dev/null +++ b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java @@ -0,0 +1,75 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for DataQuery + */ +class DataQueryTest { + private final DataQuery model = new DataQuery(); + + /** + * Model tests for DataQuery + */ + @Test + void testDataQuery() { + // TODO: test DataQuery + } + + /** + * Test the property 'text' + */ + @Test + void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + void dateTest() { + // TODO: test date + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/QueryTest.java b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/QueryTest.java new file mode 100644 index 00000000000..5b896d41d1c --- /dev/null +++ b/samples/client/echo_api/java/feign-gson/src/test/java/org/openapitools/client/model/QueryTest.java @@ -0,0 +1,57 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for Query + */ +class QueryTest { + private final Query model = new Query(); + + /** + * Model tests for Query + */ + @Test + void testQuery() { + // TODO: test Query + } + + /** + * Test the property 'id' + */ + @Test + void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/echo_api/java/native/.openapi-generator/FILES b/samples/client/echo_api/java/native/.openapi-generator/FILES index 27c16a6a48e..90a697b6ff2 100644 --- a/samples/client/echo_api/java/native/.openapi-generator/FILES +++ b/samples/client/echo_api/java/native/.openapi-generator/FILES @@ -8,8 +8,11 @@ build.sbt docs/Bird.md docs/BodyApi.md docs/Category.md +docs/DataQuery.md +docs/DataQueryAllOf.md docs/PathApi.md docs/Pet.md +docs/Query.md docs/QueryApi.md docs/Tag.md docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md @@ -38,7 +41,10 @@ src/main/java/org/openapitools/client/api/QueryApi.java src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java src/main/java/org/openapitools/client/model/Bird.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/DataQuery.java +src/main/java/org/openapitools/client/model/DataQueryAllOf.java src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Query.java src/main/java/org/openapitools/client/model/Tag.java src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java diff --git a/samples/client/echo_api/java/native/README.md b/samples/client/echo_api/java/native/README.md index 85306780fad..55864e1c18d 100644 --- a/samples/client/echo_api/java/native/README.md +++ b/samples/client/echo_api/java/native/README.md @@ -119,13 +119,18 @@ Class | Method | HTTP request | Description *QueryApi* | [**testQueryStyleFormExplodeTrueArrayStringWithHttpInfo**](docs/QueryApi.md#testQueryStyleFormExplodeTrueArrayStringWithHttpInfo) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) *QueryApi* | [**testQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) *QueryApi* | [**testQueryStyleFormExplodeTrueObjectWithHttpInfo**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObjectWithHttpInfo) | **GET** /query/style_form/explode_true/object | Test query parameter(s) +*QueryApi* | [**testQueryStyleFormExplodeTrueObjectAllOf**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) +*QueryApi* | [**testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) ## Documentation for Models - [Bird](docs/Bird.md) - [Category](docs/Category.md) + - [DataQuery](docs/DataQuery.md) + - [DataQueryAllOf](docs/DataQueryAllOf.md) - [Pet](docs/Pet.md) + - [Query](docs/Query.md) - [Tag](docs/Tag.md) - [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md) - [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md) diff --git a/samples/client/echo_api/java/native/api/openapi.yaml b/samples/client/echo_api/java/native/api/openapi.yaml index 93bbf6fbd08..3fc6ac3d6c8 100644 --- a/samples/client/echo_api/java/native/api/openapi.yaml +++ b/samples/client/echo_api/java/native/api/openapi.yaml @@ -124,6 +124,29 @@ paths: tags: - query x-accepts: text/plain + /query/style_form/explode_true/object/allOf: + get: + description: Test query parameter(s) + operationId: test/query/style_form/explode_true/object/allOf + parameters: + - explode: true + in: query + name: query_object + required: false + schema: + $ref: '#/components/schemas/DataQuery' + style: form + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test query parameter(s) + tags: + - query + x-accepts: text/plain /query/style_deepObject/explode_true/object: get: description: Test query parameter(s) @@ -285,6 +308,29 @@ components: color: type: string type: object + Query: + properties: + id: + description: Query + format: int64 + type: integer + outcomes: + default: + - SUCCESS + - FAILURE + items: + enum: + - SUCCESS + - FAILURE + - SKIPPED + type: string + type: array + type: object + x-parent: true + DataQuery: + allOf: + - $ref: '#/components/schemas/DataQuery_allOf' + - $ref: '#/components/schemas/Query' test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: @@ -296,4 +342,19 @@ components: allOf: - $ref: '#/components/schemas/Bird' - $ref: '#/components/schemas/Category' + DataQuery_allOf: + properties: + suffix: + description: test suffix + type: string + text: + description: Some text containing white spaces + example: Some text + type: string + date: + description: A date + format: date-time + type: string + type: object + example: null diff --git a/samples/client/echo_api/java/native/docs/DataQuery.md b/samples/client/echo_api/java/native/docs/DataQuery.md new file mode 100644 index 00000000000..338c467b2d5 --- /dev/null +++ b/samples/client/echo_api/java/native/docs/DataQuery.md @@ -0,0 +1,15 @@ + + +# DataQuery + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**suffix** | **String** | test suffix | [optional] | +|**text** | **String** | Some text containing white spaces | [optional] | +|**date** | **OffsetDateTime** | A date | [optional] | + + + diff --git a/samples/client/echo_api/java/native/docs/DataQueryAllOf.md b/samples/client/echo_api/java/native/docs/DataQueryAllOf.md new file mode 100644 index 00000000000..cc8aa2952e9 --- /dev/null +++ b/samples/client/echo_api/java/native/docs/DataQueryAllOf.md @@ -0,0 +1,15 @@ + + +# DataQueryAllOf + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**suffix** | **String** | test suffix | [optional] | +|**text** | **String** | Some text containing white spaces | [optional] | +|**date** | **OffsetDateTime** | A date | [optional] | + + + diff --git a/samples/client/echo_api/java/native/docs/Query.md b/samples/client/echo_api/java/native/docs/Query.md new file mode 100644 index 00000000000..99c6fd6faa5 --- /dev/null +++ b/samples/client/echo_api/java/native/docs/Query.md @@ -0,0 +1,24 @@ + + +# Query + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | Query | [optional] | +|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | + + + +## Enum: List<OutcomesEnum> + +| Name | Value | +|---- | -----| +| SUCCESS | "SUCCESS" | +| FAILURE | "FAILURE" | +| SKIPPED | "SKIPPED" | + + + diff --git a/samples/client/echo_api/java/native/docs/QueryApi.md b/samples/client/echo_api/java/native/docs/QueryApi.md index 2836b4f7474..88778049f68 100644 --- a/samples/client/echo_api/java/native/docs/QueryApi.md +++ b/samples/client/echo_api/java/native/docs/QueryApi.md @@ -14,6 +14,8 @@ All URIs are relative to *http://localhost:3000* | [**testQueryStyleFormExplodeTrueArrayStringWithHttpInfo**](QueryApi.md#testQueryStyleFormExplodeTrueArrayStringWithHttpInfo) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) | | [**testQueryStyleFormExplodeTrueObject**](QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) | | [**testQueryStyleFormExplodeTrueObjectWithHttpInfo**](QueryApi.md#testQueryStyleFormExplodeTrueObjectWithHttpInfo) | **GET** /query/style_form/explode_true/object | Test query parameter(s) | +| [**testQueryStyleFormExplodeTrueObjectAllOf**](QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) | +| [**testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo**](QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) | @@ -694,3 +696,137 @@ No authorization required |-------------|-------------|------------------| | **200** | Successful operation | - | + +## testQueryStyleFormExplodeTrueObjectAllOf + +> String testQueryStyleFormExplodeTrueObjectAllOf(queryObject) + +Test query parameter(s) + +Test query parameter(s) + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.QueryApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + QueryApi apiInstance = new QueryApi(defaultClient); + DataQuery queryObject = new DataQuery(); // DataQuery | + try { + String result = apiInstance.testQueryStyleFormExplodeTrueObjectAllOf(queryObject); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling QueryApi#testQueryStyleFormExplodeTrueObjectAllOf"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **queryObject** | [**DataQuery**](.md)| | [optional] | + +### Return type + +**String** + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + +## testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo + +> ApiResponse testQueryStyleFormExplodeTrueObjectAllOf testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(queryObject) + +Test query parameter(s) + +Test query parameter(s) + +### Example + +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.ApiResponse; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.QueryApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + QueryApi apiInstance = new QueryApi(defaultClient); + DataQuery queryObject = new DataQuery(); // DataQuery | + try { + ApiResponse response = apiInstance.testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(queryObject); + System.out.println("Status code: " + response.getStatusCode()); + System.out.println("Response headers: " + response.getHeaders()); + System.out.println("Response body: " + response.getData()); + } catch (ApiException e) { + System.err.println("Exception when calling QueryApi#testQueryStyleFormExplodeTrueObjectAllOf"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **queryObject** | [**DataQuery**](.md)| | [optional] | + +### Return type + +ApiResponse<**String**> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/java/native/docs/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.md b/samples/client/echo_api/java/native/docs/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.md new file mode 100644 index 00000000000..a3635bf5c18 --- /dev/null +++ b/samples/client/echo_api/java/native/docs/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.md @@ -0,0 +1,16 @@ + + +# TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**size** | **String** | | [optional] | +|**color** | **String** | | [optional] | +|**id** | **Long** | | [optional] | +|**name** | **String** | | [optional] | + + + diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java index c5498c549bf..5c25bc122a5 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/api/QueryApi.java @@ -17,6 +17,7 @@ import org.openapitools.client.ApiException; import org.openapitools.client.ApiResponse; import org.openapitools.client.Pair; +import org.openapitools.client.model.DataQuery; import org.openapitools.client.model.Pet; import org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter; import org.openapitools.client.model.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter; @@ -143,7 +144,7 @@ public class QueryApi { String localVarPath = "/query/integer/boolean/string"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "integer_query"; localVarQueryParams.addAll(ApiClient.parameterToPairs("integer_query", integerQuery)); @@ -152,11 +153,11 @@ public class QueryApi { localVarQueryParameterBaseName = "string_query"; localVarQueryParams.addAll(ApiClient.parameterToPairs("string_query", stringQuery)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -237,18 +238,18 @@ public class QueryApi { String localVarPath = "/query/style_deepObject/explode_true/object"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query_object"; if (queryObject != null) { - localVarQueryDeepObjectStringJoiner.add(queryObject.toUrlQueryString("query_object")); + localVarQueryStringJoiner.add(queryObject.toUrlQueryString("query_object")); } - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -329,18 +330,18 @@ public class QueryApi { String localVarPath = "/query/style_deepObject/explode_true/object/allOf"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query_object"; if (queryObject != null) { - localVarQueryDeepObjectStringJoiner.add(queryObject.toUrlQueryString("query_object")); + localVarQueryStringJoiner.add(queryObject.toUrlQueryString("query_object")); } - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -421,16 +422,16 @@ public class QueryApi { String localVarPath = "/query/style_form/explode_true/array_string"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query_object"; localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "values", queryObject.getValues())); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -511,7 +512,7 @@ public class QueryApi { String localVarPath = "/query/style_form/explode_true/object"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query_object"; localVarQueryParams.addAll(ApiClient.parameterToPairs("id", queryObject.getId())); @@ -521,11 +522,101 @@ public class QueryApi { localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "tags", queryObject.getTags())); localVarQueryParams.addAll(ApiClient.parameterToPairs("status", queryObject.getStatus())); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "text/plain"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @return String + * @throws ApiException if fails to make API call + */ + public String testQueryStyleFormExplodeTrueObjectAllOf(DataQuery queryObject) throws ApiException { + ApiResponse localVarResponse = testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(queryObject); + return localVarResponse.getData(); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @return ApiResponse<String> + * @throws ApiException if fails to make API call + */ + public ApiResponse testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(DataQuery queryObject) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = testQueryStyleFormExplodeTrueObjectAllOfRequestBuilder(queryObject); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("testQueryStyleFormExplodeTrueObjectAllOf", localVarResponse); + } + // for plain text response + if (localVarResponse.headers().map().containsKey("Content-Type") && + "text/plain".equalsIgnoreCase(localVarResponse.headers().map().get("Content-Type").get(0))) { + java.util.Scanner s = new java.util.Scanner(localVarResponse.body()).useDelimiter("\\A"); + String responseBodyText = s.hasNext() ? s.next() : ""; + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBodyText + ); + } else { + throw new RuntimeException("Error! The response Content-Type is supposed to be `text/plain` but it's not: " + localVarResponse); + } + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder testQueryStyleFormExplodeTrueObjectAllOfRequestBuilder(DataQuery queryObject) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/query/style_form/explode_true/object/allOf"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "query_object"; + localVarQueryStringJoiner.add(queryObject.toUrlQueryString(null)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java index b3335005448..7bc3649a863 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Bird.java @@ -138,6 +138,15 @@ public class Bird { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Bird { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `size` to the URL query string if (getSize() != null) { - joiner.add(String.format("%s[size]=%s", prefix, URLEncoder.encode(String.valueOf(getSize()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java index 4756fae367e..d647aea29bf 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Category.java @@ -138,6 +138,15 @@ public class Category { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Category { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java new file mode 100644 index 00000000000..23fd24cf179 --- /dev/null +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQuery.java @@ -0,0 +1,242 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * DataQuery + */ +@JsonPropertyOrder({ + DataQuery.JSON_PROPERTY_SUFFIX, + DataQuery.JSON_PROPERTY_TEXT, + DataQuery.JSON_PROPERTY_DATE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { + public static final String JSON_PROPERTY_SUFFIX = "suffix"; + private String suffix; + + public static final String JSON_PROPERTY_TEXT = "text"; + private String text; + + public static final String JSON_PROPERTY_DATE = "date"; + private OffsetDateTime date; + + public DataQuery() { + } + + public DataQuery suffix(String suffix) { + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSuffix() { + return suffix; + } + + + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQuery text(String text) { + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getText() { + return text; + } + + + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setText(String text) { + this.text = text; + } + + + public DataQuery date(OffsetDateTime date) { + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public OffsetDateTime getDate() { + return date; + } + + + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + /** + * Return true if this DataQuery object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQuery dataQuery = (DataQuery) o; + return Objects.equals(this.suffix, dataQuery.suffix) && + Objects.equals(this.text, dataQuery.text) && + Objects.equals(this.date, dataQuery.date) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `suffix` to the URL query string + if (getSuffix() != null) { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `text` to the URL query string + if (getText() != null) { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `date` to the URL query string + if (getDate() != null) { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `outcomes` to the URL query string + if (getOutcomes() != null) { + for (int i = 0; i < getOutcomes().size(); i++) { + joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getOutcomes().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + return joiner.toString(); + } +} + diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java new file mode 100644 index 00000000000..16f726a615b --- /dev/null +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -0,0 +1,223 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * DataQueryAllOf + */ +@JsonPropertyOrder({ + DataQueryAllOf.JSON_PROPERTY_SUFFIX, + DataQueryAllOf.JSON_PROPERTY_TEXT, + DataQueryAllOf.JSON_PROPERTY_DATE +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQueryAllOf { + public static final String JSON_PROPERTY_SUFFIX = "suffix"; + private String suffix; + + public static final String JSON_PROPERTY_TEXT = "text"; + private String text; + + public static final String JSON_PROPERTY_DATE = "date"; + private OffsetDateTime date; + + public DataQueryAllOf() { + } + + public DataQueryAllOf suffix(String suffix) { + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSuffix() { + return suffix; + } + + + @JsonProperty(JSON_PROPERTY_SUFFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQueryAllOf text(String text) { + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getText() { + return text; + } + + + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setText(String text) { + this.text = text; + } + + + public DataQueryAllOf date(OffsetDateTime date) { + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public OffsetDateTime getDate() { + return date; + } + + + @JsonProperty(JSON_PROPERTY_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + /** + * Return true if this DataQuery_allOf object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQueryAllOf dataQueryAllOf = (DataQueryAllOf) o; + return Objects.equals(this.suffix, dataQueryAllOf.suffix) && + Objects.equals(this.text, dataQueryAllOf.text) && + Objects.equals(this.date, dataQueryAllOf.date); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQueryAllOf {\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `suffix` to the URL query string + if (getSuffix() != null) { + joiner.add(String.format("%ssuffix%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSuffix()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `text` to the URL query string + if (getText() != null) { + joiner.add(String.format("%stext%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getText()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `date` to the URL query string + if (getDate() != null) { + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java index 04bb4ce72dc..5e38df45aaf 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Pet.java @@ -316,6 +316,15 @@ public class Pet { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -323,31 +332,43 @@ public class Pet { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `category` to the URL query string if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "[category]")); + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); } // add `photoUrls` to the URL query string if (getPhotoUrls() != null) { for (int i = 0; i < getPhotoUrls().size(); i++) { - joiner.add(String.format("%s[photoUrls][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } @@ -355,14 +376,15 @@ public class Pet { if (getTags() != null) { for (int i = 0; i < getTags().size(); i++) { if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%s[tags][%d]", prefix, i))); + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } // add `status` to the URL query string if (getStatus() != null) { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java new file mode 100644 index 00000000000..287716592f3 --- /dev/null +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Query.java @@ -0,0 +1,237 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * Query + */ +@JsonPropertyOrder({ + Query.JSON_PROPERTY_ID, + Query.JSON_PROPERTY_OUTCOMES +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Query { + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + /** + * Gets or Sets outcomes + */ + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_OUTCOMES = "outcomes"; + private List outcomes = null; + + public Query() { + } + + public Query id(Long id) { + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(Long id) { + this.id = id; + } + + + public Query outcomes(List outcomes) { + this.outcomes = outcomes; + return this; + } + + public Query addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public List getOutcomes() { + return outcomes; + } + + + @JsonProperty(JSON_PROPERTY_OUTCOMES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + + /** + * Return true if this Query object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Query query = (Query) o; + return Objects.equals(this.id, query.id) && + Objects.equals(this.outcomes, query.outcomes); + } + + @Override + public int hashCode() { + return Objects.hash(id, outcomes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Query {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `outcomes` to the URL query string + if (getOutcomes() != null) { + for (int i = 0; i < getOutcomes().size(); i++) { + joiner.add(String.format("%soutcomes%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getOutcomes().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + } + + return joiner.toString(); + } +} + diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Tag.java index 55d9a7487e7..b134d68f433 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/Tag.java @@ -138,6 +138,15 @@ public class Tag { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Tag { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java index b1ae2ae8a98..fbf31f71118 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java @@ -200,6 +200,15 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -207,30 +216,40 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `size` to the URL query string if (getSize() != null) { - joiner.add(String.format("%s[size]=%s", prefix, URLEncoder.encode(String.valueOf(getSize()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssize%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSize()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java index d64cccbf0ee..efeaf3133cc 100644 --- a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java @@ -117,6 +117,15 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -124,8 +133,18 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -133,7 +152,9 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter { // add `values` to the URL query string if (getValues() != null) { for (int i = 0; i < getValues().size(); i++) { - joiner.add(String.format("%s[values][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getValues().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%svalues%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getValues().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.java b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.java new file mode 100644 index 00000000000..e1d429868dd --- /dev/null +++ b/samples/client/echo_api/java/native/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.java @@ -0,0 +1,239 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.StringJoiner; +import java.util.Objects; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + + +/** + * TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter + */ +@JsonPropertyOrder({ + TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.JSON_PROPERTY_SIZE, + TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.JSON_PROPERTY_COLOR, + TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.JSON_PROPERTY_ID, + TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.JSON_PROPERTY_NAME +}) +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter { + public static final String JSON_PROPERTY_SIZE = "size"; + private String size; + + public static final String JSON_PROPERTY_COLOR = "color"; + private String color; + + public static final String JSON_PROPERTY_ID = "id"; + private Long id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter() { + } + + public TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter size(String size) { + this.size = size; + return this; + } + + /** + * Get size + * @return size + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getSize() { + return size; + } + + + @JsonProperty(JSON_PROPERTY_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSize(String size) { + this.size = size; + } + + + public TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter color(String color) { + this.color = color; + return this; + } + + /** + * Get color + * @return color + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_COLOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getColor() { + return color; + } + + + @JsonProperty(JSON_PROPERTY_COLOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setColor(String color) { + this.color = color; + } + + + public TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter id(Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public Long getId() { + return id; + } + + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(Long id) { + this.id = id; + } + + + public TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + + public String getName() { + return name; + } + + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + + /** + * Return true if this test_query_style_form_explode_true_object_allOf_query_object_parameter object is equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter testQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter = (TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter) o; + return Objects.equals(this.size, testQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.size) && + Objects.equals(this.color, testQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.color) && + Objects.equals(this.id, testQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.id) && + Objects.equals(this.name, testQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter.name); + } + + @Override + public int hashCode() { + return Objects.hash(size, color, id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter {\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + if (prefix == null) { + prefix = ""; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `size` to the URL query string + if (getSize() != null) { + joiner.add(String.format("%s[size]=%s", prefix, URLEncoder.encode(String.valueOf(getSize()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `color` to the URL query string + if (getColor() != null) { + joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `id` to the URL query string + if (getId() != null) { + joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + // add `name` to the URL query string + if (getName() != null) { + joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + } + + return joiner.toString(); + } +} + diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java index 75dc1444916..1c6db656c4f 100644 --- a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java +++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/CustomTest.java @@ -71,6 +71,24 @@ public class CustomTest { Assert.assertEquals("/query/style_form/explode_true/object?id=12345&name=Hello%20World&category=class%20Category%20%7B%0A%20%20%20%20id%3A%20987%0A%20%20%20%20name%3A%20new%20category%0A%7D&photoUrls=http%3A%2F%2Fa.com&photoUrls=http%3A%2F%2Fb.com", p.path); } + /** + * Test query parameter(s) + *

+ * Test query parameter(s) + * + * @throws ApiException if the Api call fails + */ + @Test + public void testQueryStyleFormExplodeTrueObjectAllOfTest() throws ApiException { + DataQuery queryObject = new DataQuery().text("Hello World"); + queryObject.setId(3487L); + queryObject.setOutcomes(Arrays.asList(Query.OutcomesEnum.SKIPPED, Query.OutcomesEnum.FAILURE)); + + String response = api.testQueryStyleFormExplodeTrueObjectAllOf(queryObject); + org.openapitools.client.EchoServerResponseParser p = new org.openapitools.client.EchoServerResponseParser(response); + Assert.assertEquals("/query/style_form/explode_true/object/allOf?text=Hello%20World&id=3487&outcomes=SKIPPED&outcomes=FAILURE", p.path); + } + /** * Test query parameter(s) *

diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java new file mode 100644 index 00000000000..8a1afad2563 --- /dev/null +++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java @@ -0,0 +1,57 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for DataQueryAllOf + */ +public class DataQueryAllOfTest { + private final DataQueryAllOf model = new DataQueryAllOf(); + + /** + * Model tests for DataQueryAllOf + */ + @Test + public void testDataQueryAllOf() { + // TODO: test DataQueryAllOf + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + public void dateTest() { + // TODO: test date + } + +} diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryTest.java new file mode 100644 index 00000000000..9b71c406586 --- /dev/null +++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/DataQueryTest.java @@ -0,0 +1,76 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for DataQuery + */ +public class DataQueryTest { + private final DataQuery model = new DataQuery(); + + /** + * Model tests for DataQuery + */ + @Test + public void testDataQuery() { + // TODO: test DataQuery + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + public void dateTest() { + // TODO: test date + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + public void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/QueryTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/QueryTest.java new file mode 100644 index 00000000000..266a3cb6739 --- /dev/null +++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/QueryTest.java @@ -0,0 +1,58 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for Query + */ +public class QueryTest { + private final Query model = new Query(); + + /** + * Model tests for Query + */ + @Test + public void testQuery() { + // TODO: test Query + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + public void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameterTest.java b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameterTest.java new file mode 100644 index 00000000000..c620d9aa9cc --- /dev/null +++ b/samples/client/echo_api/java/native/src/test/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameterTest.java @@ -0,0 +1,72 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter + */ +public class TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameterTest { + private final TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter model = new TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter(); + + /** + * Model tests for TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter + */ + @Test + public void testTestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter() { + // TODO: test TestQueryStyleFormExplodeTrueObjectAllOfQueryObjectParameter + } + + /** + * Test the property 'size' + */ + @Test + public void sizeTest() { + // TODO: test size + } + + /** + * Test the property 'color' + */ + @Test + public void colorTest() { + // TODO: test color + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'name' + */ + @Test + public void nameTest() { + // TODO: test name + } + +} diff --git a/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES b/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES index 9160436563f..0492026a89c 100644 --- a/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES +++ b/samples/client/echo_api/java/okhttp-gson/.openapi-generator/FILES @@ -8,8 +8,11 @@ build.sbt docs/Bird.md docs/BodyApi.md docs/Category.md +docs/DataQuery.md +docs/DataQueryAllOf.md docs/PathApi.md docs/Pet.md +docs/Query.md docs/QueryApi.md docs/Tag.md docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md @@ -46,7 +49,10 @@ src/main/java/org/openapitools/client/auth/HttpBearerAuth.java src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java src/main/java/org/openapitools/client/model/Bird.java src/main/java/org/openapitools/client/model/Category.java +src/main/java/org/openapitools/client/model/DataQuery.java +src/main/java/org/openapitools/client/model/DataQueryAllOf.java src/main/java/org/openapitools/client/model/Pet.java +src/main/java/org/openapitools/client/model/Query.java src/main/java/org/openapitools/client/model/Tag.java src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java diff --git a/samples/client/echo_api/java/okhttp-gson/README.md b/samples/client/echo_api/java/okhttp-gson/README.md index 89f43077d05..b9fb0fdd274 100644 --- a/samples/client/echo_api/java/okhttp-gson/README.md +++ b/samples/client/echo_api/java/okhttp-gson/README.md @@ -120,13 +120,17 @@ Class | Method | HTTP request | Description *QueryApi* | [**testQueryStyleDeepObjectExplodeTrueObjectAllOf**](docs/QueryApi.md#testQueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) *QueryApi* | [**testQueryStyleFormExplodeTrueArrayString**](docs/QueryApi.md#testQueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) *QueryApi* | [**testQueryStyleFormExplodeTrueObject**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) +*QueryApi* | [**testQueryStyleFormExplodeTrueObjectAllOf**](docs/QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) ## Documentation for Models - [Bird](docs/Bird.md) - [Category](docs/Category.md) + - [DataQuery](docs/DataQuery.md) + - [DataQueryAllOf](docs/DataQueryAllOf.md) - [Pet](docs/Pet.md) + - [Query](docs/Query.md) - [Tag](docs/Tag.md) - [TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter](docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md) - [TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter](docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md) diff --git a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml index 93bbf6fbd08..3fc6ac3d6c8 100644 --- a/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml +++ b/samples/client/echo_api/java/okhttp-gson/api/openapi.yaml @@ -124,6 +124,29 @@ paths: tags: - query x-accepts: text/plain + /query/style_form/explode_true/object/allOf: + get: + description: Test query parameter(s) + operationId: test/query/style_form/explode_true/object/allOf + parameters: + - explode: true + in: query + name: query_object + required: false + schema: + $ref: '#/components/schemas/DataQuery' + style: form + responses: + "200": + content: + text/plain: + schema: + type: string + description: Successful operation + summary: Test query parameter(s) + tags: + - query + x-accepts: text/plain /query/style_deepObject/explode_true/object: get: description: Test query parameter(s) @@ -285,6 +308,29 @@ components: color: type: string type: object + Query: + properties: + id: + description: Query + format: int64 + type: integer + outcomes: + default: + - SUCCESS + - FAILURE + items: + enum: + - SUCCESS + - FAILURE + - SKIPPED + type: string + type: array + type: object + x-parent: true + DataQuery: + allOf: + - $ref: '#/components/schemas/DataQuery_allOf' + - $ref: '#/components/schemas/Query' test_query_style_form_explode_true_array_string_query_object_parameter: properties: values: @@ -296,4 +342,19 @@ components: allOf: - $ref: '#/components/schemas/Bird' - $ref: '#/components/schemas/Category' + DataQuery_allOf: + properties: + suffix: + description: test suffix + type: string + text: + description: Some text containing white spaces + example: Some text + type: string + date: + description: A date + format: date-time + type: string + type: object + example: null diff --git a/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md b/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md new file mode 100644 index 00000000000..338c467b2d5 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/docs/DataQuery.md @@ -0,0 +1,15 @@ + + +# DataQuery + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**suffix** | **String** | test suffix | [optional] | +|**text** | **String** | Some text containing white spaces | [optional] | +|**date** | **OffsetDateTime** | A date | [optional] | + + + diff --git a/samples/client/echo_api/java/okhttp-gson/docs/DataQueryAllOf.md b/samples/client/echo_api/java/okhttp-gson/docs/DataQueryAllOf.md new file mode 100644 index 00000000000..cc8aa2952e9 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/docs/DataQueryAllOf.md @@ -0,0 +1,15 @@ + + +# DataQueryAllOf + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**suffix** | **String** | test suffix | [optional] | +|**text** | **String** | Some text containing white spaces | [optional] | +|**date** | **OffsetDateTime** | A date | [optional] | + + + diff --git a/samples/client/echo_api/java/okhttp-gson/docs/Query.md b/samples/client/echo_api/java/okhttp-gson/docs/Query.md new file mode 100644 index 00000000000..99c6fd6faa5 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/docs/Query.md @@ -0,0 +1,24 @@ + + +# Query + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Long** | Query | [optional] | +|**outcomes** | [**List<OutcomesEnum>**](#List<OutcomesEnum>) | | [optional] | + + + +## Enum: List<OutcomesEnum> + +| Name | Value | +|---- | -----| +| SUCCESS | "SUCCESS" | +| FAILURE | "FAILURE" | +| SKIPPED | "SKIPPED" | + + + diff --git a/samples/client/echo_api/java/okhttp-gson/docs/QueryApi.md b/samples/client/echo_api/java/okhttp-gson/docs/QueryApi.md index a1d731dfff0..8ad27f148c1 100644 --- a/samples/client/echo_api/java/okhttp-gson/docs/QueryApi.md +++ b/samples/client/echo_api/java/okhttp-gson/docs/QueryApi.md @@ -9,6 +9,7 @@ All URIs are relative to *http://localhost:3000* | [**testQueryStyleDeepObjectExplodeTrueObjectAllOf**](QueryApi.md#testQueryStyleDeepObjectExplodeTrueObjectAllOf) | **GET** /query/style_deepObject/explode_true/object/allOf | Test query parameter(s) | | [**testQueryStyleFormExplodeTrueArrayString**](QueryApi.md#testQueryStyleFormExplodeTrueArrayString) | **GET** /query/style_form/explode_true/array_string | Test query parameter(s) | | [**testQueryStyleFormExplodeTrueObject**](QueryApi.md#testQueryStyleFormExplodeTrueObject) | **GET** /query/style_form/explode_true/object | Test query parameter(s) | +| [**testQueryStyleFormExplodeTrueObjectAllOf**](QueryApi.md#testQueryStyleFormExplodeTrueObjectAllOf) | **GET** /query/style_form/explode_true/object/allOf | Test query parameter(s) | @@ -325,3 +326,65 @@ No authorization required |-------------|-------------|------------------| | **200** | Successful operation | - | + +# **testQueryStyleFormExplodeTrueObjectAllOf** +> String testQueryStyleFormExplodeTrueObjectAllOf(queryObject) + +Test query parameter(s) + +Test query parameter(s) + +### Example +```java +// Import classes: +import org.openapitools.client.ApiClient; +import org.openapitools.client.ApiException; +import org.openapitools.client.Configuration; +import org.openapitools.client.models.*; +import org.openapitools.client.api.QueryApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost:3000"); + + QueryApi apiInstance = new QueryApi(defaultClient); + DataQuery queryObject = new DataQuery(); // DataQuery | + try { + String result = apiInstance.testQueryStyleFormExplodeTrueObjectAllOf(queryObject); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling QueryApi#testQueryStyleFormExplodeTrueObjectAllOf"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **queryObject** | [**DataQuery**](.md)| | [optional] | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Successful operation | - | + diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java index 51074c16658..89f5cec6d71 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/JSON.java @@ -95,6 +95,8 @@ public class JSON { gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Bird.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQuery.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DataQueryAllOf.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.CustomTypeAdapterFactory()); diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/QueryApi.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/QueryApi.java index b1adb6f21ff..5de166dadd3 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/QueryApi.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/api/QueryApi.java @@ -27,6 +27,7 @@ import com.google.gson.reflect.TypeToken; import java.io.IOException; +import org.openapitools.client.model.DataQuery; import org.openapitools.client.model.Pet; import org.openapitools.client.model.TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter; import org.openapitools.client.model.TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter; @@ -696,4 +697,125 @@ public class QueryApi { localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for testQueryStyleFormExplodeTrueObjectAllOf + * @param queryObject (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public okhttp3.Call testQueryStyleFormExplodeTrueObjectAllOfCall(DataQuery queryObject, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/query/style_form/explode_true/object/allOf"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (queryObject != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("query_object", queryObject)); + } + + final String[] localVarAccepts = { + "text/plain" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call testQueryStyleFormExplodeTrueObjectAllOfValidateBeforeCall(DataQuery queryObject, final ApiCallback _callback) throws ApiException { + return testQueryStyleFormExplodeTrueObjectAllOfCall(queryObject, _callback); + + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @return String + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public String testQueryStyleFormExplodeTrueObjectAllOf(DataQuery queryObject) throws ApiException { + ApiResponse localVarResp = testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(queryObject); + return localVarResp.getData(); + } + + /** + * Test query parameter(s) + * Test query parameter(s) + * @param queryObject (optional) + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public ApiResponse testQueryStyleFormExplodeTrueObjectAllOfWithHttpInfo(DataQuery queryObject) throws ApiException { + okhttp3.Call localVarCall = testQueryStyleFormExplodeTrueObjectAllOfValidateBeforeCall(queryObject, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Test query parameter(s) (asynchronously) + * Test query parameter(s) + * @param queryObject (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 Successful operation -
+ */ + public okhttp3.Call testQueryStyleFormExplodeTrueObjectAllOfAsync(DataQuery queryObject, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = testQueryStyleFormExplodeTrueObjectAllOfValidateBeforeCall(queryObject, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } } diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java new file mode 100644 index 00000000000..52c90035ee5 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java @@ -0,0 +1,274 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * DataQuery + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQuery extends Query { + public static final String SERIALIZED_NAME_SUFFIX = "suffix"; + @SerializedName(SERIALIZED_NAME_SUFFIX) + private String suffix; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + private String text; + + public static final String SERIALIZED_NAME_DATE = "date"; + @SerializedName(SERIALIZED_NAME_DATE) + private OffsetDateTime date; + + public DataQuery() { + } + + public DataQuery suffix(String suffix) { + + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + + public String getSuffix() { + return suffix; + } + + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQuery text(String text) { + + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + + public String getText() { + return text; + } + + + public void setText(String text) { + this.text = text; + } + + + public DataQuery date(OffsetDateTime date) { + + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + + public OffsetDateTime getDate() { + return date; + } + + + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQuery dataQuery = (DataQuery) o; + return Objects.equals(this.suffix, dataQuery.suffix) && + Objects.equals(this.text, dataQuery.text) && + Objects.equals(this.date, dataQuery.date) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQuery {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("suffix"); + openapiFields.add("text"); + openapiFields.add("date"); + openapiFields.add("id"); + openapiFields.add("outcomes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DataQuery + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!DataQuery.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in DataQuery is not found in the empty JSON string", DataQuery.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!DataQuery.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DataQuery` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("suffix") != null && !jsonObj.get("suffix").isJsonNull()) && !jsonObj.get("suffix").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suffix` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suffix").toString())); + } + if ((jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) && !jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DataQuery.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DataQuery' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DataQuery.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DataQuery value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public DataQuery read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DataQuery given an JSON string + * + * @param jsonString JSON string + * @return An instance of DataQuery + * @throws IOException if the JSON string is invalid with respect to DataQuery + */ + public static DataQuery fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DataQuery.class); + } + + /** + * Convert an instance of DataQuery to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java new file mode 100644 index 00000000000..950251095b3 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQueryAllOf.java @@ -0,0 +1,267 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * DataQueryAllOf + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DataQueryAllOf { + public static final String SERIALIZED_NAME_SUFFIX = "suffix"; + @SerializedName(SERIALIZED_NAME_SUFFIX) + private String suffix; + + public static final String SERIALIZED_NAME_TEXT = "text"; + @SerializedName(SERIALIZED_NAME_TEXT) + private String text; + + public static final String SERIALIZED_NAME_DATE = "date"; + @SerializedName(SERIALIZED_NAME_DATE) + private OffsetDateTime date; + + public DataQueryAllOf() { + } + + public DataQueryAllOf suffix(String suffix) { + + this.suffix = suffix; + return this; + } + + /** + * test suffix + * @return suffix + **/ + @javax.annotation.Nullable + + public String getSuffix() { + return suffix; + } + + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + + public DataQueryAllOf text(String text) { + + this.text = text; + return this; + } + + /** + * Some text containing white spaces + * @return text + **/ + @javax.annotation.Nullable + + public String getText() { + return text; + } + + + public void setText(String text) { + this.text = text; + } + + + public DataQueryAllOf date(OffsetDateTime date) { + + this.date = date; + return this; + } + + /** + * A date + * @return date + **/ + @javax.annotation.Nullable + + public OffsetDateTime getDate() { + return date; + } + + + public void setDate(OffsetDateTime date) { + this.date = date; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DataQueryAllOf dataQueryAllOf = (DataQueryAllOf) o; + return Objects.equals(this.suffix, dataQueryAllOf.suffix) && + Objects.equals(this.text, dataQueryAllOf.text) && + Objects.equals(this.date, dataQueryAllOf.date); + } + + @Override + public int hashCode() { + return Objects.hash(suffix, text, date); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DataQueryAllOf {\n"); + sb.append(" suffix: ").append(toIndentedString(suffix)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("suffix"); + openapiFields.add("text"); + openapiFields.add("date"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to DataQueryAllOf + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!DataQueryAllOf.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in DataQueryAllOf is not found in the empty JSON string", DataQueryAllOf.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!DataQueryAllOf.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DataQueryAllOf` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("suffix") != null && !jsonObj.get("suffix").isJsonNull()) && !jsonObj.get("suffix").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `suffix` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suffix").toString())); + } + if ((jsonObj.get("text") != null && !jsonObj.get("text").isJsonNull()) && !jsonObj.get("text").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `text` to be a primitive type in the JSON string but got `%s`", jsonObj.get("text").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DataQueryAllOf.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DataQueryAllOf' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(DataQueryAllOf.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, DataQueryAllOf value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public DataQueryAllOf read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of DataQueryAllOf given an JSON string + * + * @param jsonString JSON string + * @return An instance of DataQueryAllOf + * @throws IOException if the JSON string is invalid with respect to DataQueryAllOf + */ + public static DataQueryAllOf fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DataQueryAllOf.class); + } + + /** + * Convert an instance of DataQueryAllOf to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java new file mode 100644 index 00000000000..0e9e9a12fa1 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java @@ -0,0 +1,258 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.openapitools.client.JSON; + +/** + * Query + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class Query { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private Long id; + + /** + * Gets or Sets outcomes + */ + @JsonAdapter(OutcomesEnum.Adapter.class) + public enum OutcomesEnum { + SUCCESS("SUCCESS"), + + FAILURE("FAILURE"), + + SKIPPED("SKIPPED"); + + private String value; + + OutcomesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OutcomesEnum fromValue(String value) { + for (OutcomesEnum b : OutcomesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final OutcomesEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public OutcomesEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return OutcomesEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_OUTCOMES = "outcomes"; + @SerializedName(SERIALIZED_NAME_OUTCOMES) + private List outcomes = null; + + public Query() { + } + + public Query id(Long id) { + + this.id = id; + return this; + } + + /** + * Query + * @return id + **/ + @javax.annotation.Nullable + + public Long getId() { + return id; + } + + + public void setId(Long id) { + this.id = id; + } + + + public Query outcomes(List outcomes) { + + this.outcomes = outcomes; + return this; + } + + public Query addOutcomesItem(OutcomesEnum outcomesItem) { + if (this.outcomes == null) { + this.outcomes = new ArrayList<>(); + } + this.outcomes.add(outcomesItem); + return this; + } + + /** + * Get outcomes + * @return outcomes + **/ + @javax.annotation.Nullable + + public List getOutcomes() { + return outcomes; + } + + + public void setOutcomes(List outcomes) { + this.outcomes = outcomes; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Query query = (Query) o; + return Objects.equals(this.id, query.id) && + Objects.equals(this.outcomes, query.outcomes); + } + + @Override + public int hashCode() { + return Objects.hash(id, outcomes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Query {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" outcomes: ").append(toIndentedString(outcomes)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("outcomes"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Query + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Query.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Query is not found in the empty JSON string", Query.openapiRequiredFields.toString())); + } + } + // ensure the optional json data is an array if present + if (jsonObj.get("outcomes") != null && !jsonObj.get("outcomes").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `outcomes` to be an array in the JSON string but got `%s`", jsonObj.get("outcomes").toString())); + } + } + + + /** + * Create an instance of Query given an JSON string + * + * @param jsonString JSON string + * @return An instance of Query + * @throws IOException if the JSON string is invalid with respect to Query + */ + public static Query fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Query.class); + } + + /** + * Convert an instance of Query to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java new file mode 100644 index 00000000000..7165591ae6d --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryAllOfTest.java @@ -0,0 +1,57 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for DataQueryAllOf + */ +public class DataQueryAllOfTest { + private final DataQueryAllOf model = new DataQueryAllOf(); + + /** + * Model tests for DataQueryAllOf + */ + @Test + public void testDataQueryAllOf() { + // TODO: test DataQueryAllOf + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + public void dateTest() { + // TODO: test date + } + +} diff --git a/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java new file mode 100644 index 00000000000..6b8ac265632 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/DataQueryTest.java @@ -0,0 +1,76 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import org.openapitools.client.model.Query; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for DataQuery + */ +public class DataQueryTest { + private final DataQuery model = new DataQuery(); + + /** + * Model tests for DataQuery + */ + @Test + public void testDataQuery() { + // TODO: test DataQuery + } + + /** + * Test the property 'text' + */ + @Test + public void textTest() { + // TODO: test text + } + + /** + * Test the property 'date' + */ + @Test + public void dateTest() { + // TODO: test date + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + public void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/QueryTest.java b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/QueryTest.java new file mode 100644 index 00000000000..e7ca10f2484 --- /dev/null +++ b/samples/client/echo_api/java/okhttp-gson/src/test/java/org/openapitools/client/model/QueryTest.java @@ -0,0 +1,58 @@ +/* + * Echo Server API + * Echo Server API + * + * The version of the OpenAPI document: 0.1.0 + * Contact: team@openapitools.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.openapitools.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + + +/** + * Model tests for Query + */ +public class QueryTest { + private final Query model = new Query(); + + /** + * Model tests for Query + */ + @Test + public void testQuery() { + // TODO: test Query + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'outcomes' + */ + @Test + public void outcomesTest() { + // TODO: test outcomes + } + +} diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 2ee4e3037bb..6f6e9b8ed1e 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -67,7 +67,7 @@ public class AnotherFakeApi { // create path and map variables String localVarPath = "/another-fake/dummy"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -96,7 +96,7 @@ public class AnotherFakeApi { "PATCH", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/DefaultApi.java index cb5d90dcf55..6045a630c1d 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -61,7 +61,7 @@ public class DefaultApi { // create path and map variables String localVarPath = "/foo"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -90,7 +90,7 @@ public class DefaultApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java index a8a972e0213..18f8b7d6d77 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeApi.java @@ -72,7 +72,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/health"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -101,7 +101,7 @@ public class FakeApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -131,7 +131,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/http-signature-test"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -162,7 +162,7 @@ public class FakeApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -186,7 +186,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/outer/boolean"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -215,7 +215,7 @@ public class FakeApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -239,7 +239,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/outer/composite"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -268,7 +268,7 @@ public class FakeApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -292,7 +292,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/outer/number"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -321,7 +321,7 @@ public class FakeApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -345,7 +345,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/outer/string"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -374,7 +374,7 @@ public class FakeApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -403,7 +403,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/property/enum-int"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -432,7 +432,7 @@ public class FakeApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -460,7 +460,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/body-with-binary"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -488,7 +488,7 @@ public class FakeApi { "PUT", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -516,7 +516,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/body-with-file-schema"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -544,7 +544,7 @@ public class FakeApi { "PUT", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -578,7 +578,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake/body-with-query-params"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -607,7 +607,7 @@ public class FakeApi { "PUT", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -636,7 +636,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -665,7 +665,7 @@ public class FakeApi { "PATCH", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -721,7 +721,7 @@ public class FakeApi { // create path and map variables String localVarPath = "/fake"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -777,7 +777,7 @@ if (paramCallback != null) "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -808,7 +808,7 @@ if (paramCallback != null) // create path and map variables String localVarPath = "/fake"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -849,7 +849,7 @@ if (enumFormString != null) "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -892,7 +892,7 @@ if (enumFormString != null) // create path and map variables String localVarPath = "/fake"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -928,7 +928,7 @@ if (booleanGroup != null) "DELETE", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -956,7 +956,7 @@ if (booleanGroup != null) // create path and map variables String localVarPath = "/fake/inline-additionalProperties"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -984,7 +984,7 @@ if (booleanGroup != null) "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -1018,7 +1018,7 @@ if (booleanGroup != null) // create path and map variables String localVarPath = "/fake/jsonFormData"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -1050,7 +1050,7 @@ if (param2 != null) "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -1109,7 +1109,7 @@ if (param2 != null) // create path and map variables String localVarPath = "/fake/test-query-parameters"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -1144,7 +1144,7 @@ if (param2 != null) "PUT", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 01f1d08283d..4e3839ffdf7 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -67,7 +67,7 @@ public class FakeClassnameTags123Api { // create path and map variables String localVarPath = "/fake_classname_test"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -96,7 +96,7 @@ public class FakeClassnameTags123Api { "PATCH", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/PetApi.java index 025cec55893..1da9b5cc1d1 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/PetApi.java @@ -69,7 +69,7 @@ public class PetApi { // create path and map variables String localVarPath = "/pet"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -97,7 +97,7 @@ public class PetApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -127,7 +127,7 @@ public class PetApi { String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -157,7 +157,7 @@ public class PetApi { "DELETE", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -186,7 +186,7 @@ public class PetApi { // create path and map variables String localVarPath = "/pet/findByStatus"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -216,7 +216,7 @@ public class PetApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -247,7 +247,7 @@ public class PetApi { // create path and map variables String localVarPath = "/pet/findByTags"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -277,7 +277,7 @@ public class PetApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -307,7 +307,7 @@ public class PetApi { String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -336,7 +336,7 @@ public class PetApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -364,7 +364,7 @@ public class PetApi { // create path and map variables String localVarPath = "/pet"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -392,7 +392,7 @@ public class PetApi { "PUT", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -423,7 +423,7 @@ public class PetApi { String localVarPath = "/pet/{petId}" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -455,7 +455,7 @@ if (status != null) "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -487,7 +487,7 @@ if (status != null) String localVarPath = "/pet/{petId}/uploadImage" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -520,7 +520,7 @@ if (_file != null) "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -557,7 +557,7 @@ if (_file != null) String localVarPath = "/fake/{petId}/uploadImageWithRequiredFile" .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -590,7 +590,7 @@ if (requiredFile != null) "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/StoreApi.java index 3174e1703e1..5ecd834878a 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/StoreApi.java @@ -67,7 +67,7 @@ public class StoreApi { String localVarPath = "/store/order/{order_id}" .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -95,7 +95,7 @@ public class StoreApi { "DELETE", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -118,7 +118,7 @@ public class StoreApi { // create path and map variables String localVarPath = "/store/inventory"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -147,7 +147,7 @@ public class StoreApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -177,7 +177,7 @@ public class StoreApi { String localVarPath = "/store/order/{order_id}" .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -206,7 +206,7 @@ public class StoreApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -235,7 +235,7 @@ public class StoreApi { // create path and map variables String localVarPath = "/store/order"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -264,7 +264,7 @@ public class StoreApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/UserApi.java index 0a6af05d2af..205427abdb8 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/api/UserApi.java @@ -67,7 +67,7 @@ public class UserApi { // create path and map variables String localVarPath = "/user"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -95,7 +95,7 @@ public class UserApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -123,7 +123,7 @@ public class UserApi { // create path and map variables String localVarPath = "/user/createWithArray"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -151,7 +151,7 @@ public class UserApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -179,7 +179,7 @@ public class UserApi { // create path and map variables String localVarPath = "/user/createWithList"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -207,7 +207,7 @@ public class UserApi { "POST", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -236,7 +236,7 @@ public class UserApi { String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -264,7 +264,7 @@ public class UserApi { "DELETE", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -294,7 +294,7 @@ public class UserApi { String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -323,7 +323,7 @@ public class UserApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -358,7 +358,7 @@ public class UserApi { // create path and map variables String localVarPath = "/user/login"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -389,7 +389,7 @@ public class UserApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -411,7 +411,7 @@ public class UserApi { // create path and map variables String localVarPath = "/user/logout"; - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -439,7 +439,7 @@ public class UserApi { "GET", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, @@ -474,7 +474,7 @@ public class UserApi { String localVarPath = "/user/{username}" .replaceAll("\\{" + "username" + "\\}", apiClient.escapeString(username.toString())); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -502,7 +502,7 @@ public class UserApi { "PUT", localVarQueryParams, localVarCollectionQueryParams, - localVarQueryDeepObjectStringJoiner.toString(), + localVarQueryStringJoiner.toString(), localVarPostBody, localVarHeaderParams, localVarCookieParams, diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java index c39269a9e0e..ba15c9f60f0 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java @@ -153,6 +153,15 @@ public class AdditionalPropertiesClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -160,32 +169,50 @@ public class AdditionalPropertiesClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `map_property` to the URL query string if (getMapProperty() != null) { for (String _key : getMapProperty().keySet()) { try { - joiner.add(String.format("%s[map_property][%s]=%s", prefix, getMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapProperty().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_property%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapProperty().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `map_of_map_property` to the URL query string if (getMapOfMapProperty() != null) { for (String _key : getMapOfMapProperty().keySet()) { try { - joiner.add(String.format("%s[map_of_map_property][%s]=%s", prefix, getMapOfMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapOfMapProperty().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_of_map_property%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapOfMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapOfMapProperty().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java index 8015cad643d..68f60026b89 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java @@ -136,6 +136,15 @@ public class AllOfWithSingleRef { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -143,23 +152,37 @@ public class AllOfWithSingleRef { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `username` to the URL query string if (getUsername() != null) { try { - joiner.add(String.format("%s[username]=%s", prefix, URLEncoder.encode(String.valueOf(getUsername()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%susername%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUsername()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `SingleRefType` to the URL query string if (getSingleRefType() != null) { - joiner.add(getSingleRefType().toUrlQueryString(prefix + "[SingleRefType]")); + joiner.add(getSingleRefType().toUrlQueryString(prefix + "SingleRefType" + suffix)); } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Animal.java index 3b0ed2dc49f..1d37baf0f8c 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Animal.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Animal.java @@ -150,6 +150,15 @@ public class Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -157,28 +166,42 @@ public class Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `className` to the URL query string if (getClassName() != null) { try { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `color` to the URL query string if (getColor() != null) { try { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java index ec22395e8f3..28c52b25098 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java @@ -114,6 +114,15 @@ public class ArrayOfArrayOfNumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -121,16 +130,30 @@ public class ArrayOfArrayOfNumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `ArrayArrayNumber` to the URL query string if (getArrayArrayNumber() != null) { for (int i = 0; i < getArrayArrayNumber().size(); i++) { if (getArrayArrayNumber().get(i) != null) { try { - joiner.add(String.format("%s[ArrayArrayNumber][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -138,6 +161,7 @@ public class ArrayOfArrayOfNumberOnly { } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java index cb11290224f..b1b948208d8 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java @@ -114,6 +114,15 @@ public class ArrayOfNumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -121,16 +130,30 @@ public class ArrayOfNumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `ArrayNumber` to the URL query string if (getArrayNumber() != null) { for (int i = 0; i < getArrayNumber().size(); i++) { if (getArrayNumber().get(i) != null) { try { - joiner.add(String.format("%s[ArrayNumber][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -138,6 +161,7 @@ public class ArrayOfNumberOnly { } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java index 00d928bb2a1..1107b2d5c1b 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayTest.java @@ -194,6 +194,15 @@ public class ArrayTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -201,38 +210,58 @@ public class ArrayTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `array_of_string` to the URL query string if (getArrayOfString() != null) { for (int i = 0; i < getArrayOfString().size(); i++) { try { - joiner.add(String.format("%s[array_of_string][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayOfString().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_of_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayOfString().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `array_array_of_integer` to the URL query string if (getArrayArrayOfInteger() != null) { for (int i = 0; i < getArrayArrayOfInteger().size(); i++) { try { - joiner.add(String.format("%s[array_array_of_integer][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayOfInteger().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_array_of_integer%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayOfInteger().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `array_array_of_model` to the URL query string if (getArrayArrayOfModel() != null) { for (int i = 0; i < getArrayArrayOfModel().size(); i++) { if (getArrayArrayOfModel().get(i) != null) { try { - joiner.add(String.format("%s[array_array_of_model][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayOfModel().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_array_of_model%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayOfModel().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -240,6 +269,7 @@ public class ArrayTest { } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Capitalization.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Capitalization.java index d4f91eba427..d0716716b6c 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Capitalization.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Capitalization.java @@ -263,6 +263,15 @@ public class Capitalization { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -270,64 +279,82 @@ public class Capitalization { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `smallCamel` to the URL query string if (getSmallCamel() != null) { try { - joiner.add(String.format("%s[smallCamel]=%s", prefix, URLEncoder.encode(String.valueOf(getSmallCamel()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssmallCamel%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSmallCamel()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `CapitalCamel` to the URL query string if (getCapitalCamel() != null) { try { - joiner.add(String.format("%s[CapitalCamel]=%s", prefix, URLEncoder.encode(String.valueOf(getCapitalCamel()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sCapitalCamel%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCapitalCamel()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `small_Snake` to the URL query string if (getSmallSnake() != null) { try { - joiner.add(String.format("%s[small_Snake]=%s", prefix, URLEncoder.encode(String.valueOf(getSmallSnake()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssmall_Snake%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSmallSnake()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `Capital_Snake` to the URL query string if (getCapitalSnake() != null) { try { - joiner.add(String.format("%s[Capital_Snake]=%s", prefix, URLEncoder.encode(String.valueOf(getCapitalSnake()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sCapital_Snake%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCapitalSnake()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `SCA_ETH_Flow_Points` to the URL query string if (getScAETHFlowPoints() != null) { try { - joiner.add(String.format("%s[SCA_ETH_Flow_Points]=%s", prefix, URLEncoder.encode(String.valueOf(getScAETHFlowPoints()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sSCA_ETH_Flow_Points%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getScAETHFlowPoints()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `ATT_NAME` to the URL query string if (getATTNAME() != null) { try { - joiner.add(String.format("%s[ATT_NAME]=%s", prefix, URLEncoder.encode(String.valueOf(getATTNAME()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sATT_NAME%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getATTNAME()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Cat.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Cat.java index 56afb577829..b3ab6517bc0 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Cat.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Cat.java @@ -116,6 +116,15 @@ public class Cat extends Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -123,37 +132,52 @@ public class Cat extends Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `className` to the URL query string if (getClassName() != null) { try { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `color` to the URL query string if (getColor() != null) { try { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `declawed` to the URL query string if (getDeclawed() != null) { try { - joiner.add(String.format("%s[declawed]=%s", prefix, URLEncoder.encode(String.valueOf(getDeclawed()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdeclawed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDeclawed()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/CatAllOf.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/CatAllOf.java index 28689452bb3..0c3637fdb67 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/CatAllOf.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/CatAllOf.java @@ -104,6 +104,15 @@ public class CatAllOf { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class CatAllOf { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `declawed` to the URL query string if (getDeclawed() != null) { try { - joiner.add(String.format("%s[declawed]=%s", prefix, URLEncoder.encode(String.valueOf(getDeclawed()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdeclawed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDeclawed()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java index 00229270d48..74267bf6985 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Category.java @@ -135,6 +135,15 @@ public class Category { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -142,28 +151,42 @@ public class Category { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ClassModel.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ClassModel.java index c1776d1f789..3d904821aaa 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ClassModel.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ClassModel.java @@ -103,6 +103,15 @@ public class ClassModel { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -110,19 +119,32 @@ public class ClassModel { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `_class` to the URL query string if (getPropertyClass() != null) { try { - joiner.add(String.format("%s[_class]=%s", prefix, URLEncoder.encode(String.valueOf(getPropertyClass()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s_class%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPropertyClass()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Client.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Client.java index a3f5e9913be..69f45c30e84 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Client.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Client.java @@ -103,6 +103,15 @@ public class Client { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -110,19 +119,32 @@ public class Client { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `client` to the URL query string if (getClient() != null) { try { - joiner.add(String.format("%s[client]=%s", prefix, URLEncoder.encode(String.valueOf(getClient()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclient%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClient()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DeprecatedObject.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DeprecatedObject.java index 2862dfaba79..842bcd1386e 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DeprecatedObject.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -105,6 +105,15 @@ public class DeprecatedObject { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -112,19 +121,32 @@ public class DeprecatedObject { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Dog.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Dog.java index 2bf6beacf19..055a293ec28 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Dog.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Dog.java @@ -116,6 +116,15 @@ public class Dog extends Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -123,37 +132,52 @@ public class Dog extends Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `className` to the URL query string if (getClassName() != null) { try { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `color` to the URL query string if (getColor() != null) { try { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `breed` to the URL query string if (getBreed() != null) { try { - joiner.add(String.format("%s[breed]=%s", prefix, URLEncoder.encode(String.valueOf(getBreed()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbreed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBreed()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DogAllOf.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DogAllOf.java index 4cc2b03f61f..8400a2ffeee 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DogAllOf.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/DogAllOf.java @@ -104,6 +104,15 @@ public class DogAllOf { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class DogAllOf { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `breed` to the URL query string if (getBreed() != null) { try { - joiner.add(String.format("%s[breed]=%s", prefix, URLEncoder.encode(String.valueOf(getBreed()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbreed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBreed()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java index 8f73270abba..98d930c37f7 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -215,6 +215,15 @@ public class EnumArrays { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -222,30 +231,46 @@ public class EnumArrays { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `just_symbol` to the URL query string if (getJustSymbol() != null) { try { - joiner.add(String.format("%s[just_symbol]=%s", prefix, URLEncoder.encode(String.valueOf(getJustSymbol()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sjust_symbol%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getJustSymbol()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `array_enum` to the URL query string if (getArrayEnum() != null) { for (int i = 0; i < getArrayEnum().size(); i++) { try { - joiner.add(String.format("%s[array_enum][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayEnum().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_enum%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayEnum().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java index 9678f9530f6..a1ec634cb06 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/EnumTest.java @@ -499,6 +499,15 @@ public class EnumTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -506,82 +515,102 @@ public class EnumTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `enum_string` to the URL query string if (getEnumString() != null) { try { - joiner.add(String.format("%s[enum_string]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumString()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_string%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumString()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `enum_string_required` to the URL query string if (getEnumStringRequired() != null) { try { - joiner.add(String.format("%s[enum_string_required]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumStringRequired()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_string_required%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumStringRequired()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `enum_integer` to the URL query string if (getEnumInteger() != null) { try { - joiner.add(String.format("%s[enum_integer]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumInteger()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_integer%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumInteger()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `enum_number` to the URL query string if (getEnumNumber() != null) { try { - joiner.add(String.format("%s[enum_number]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumNumber()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumNumber()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `outerEnum` to the URL query string if (getOuterEnum() != null) { try { - joiner.add(String.format("%s[outerEnum]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnum()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnum%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnum()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `outerEnumInteger` to the URL query string if (getOuterEnumInteger() != null) { try { - joiner.add(String.format("%s[outerEnumInteger]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumInteger()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumInteger%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumInteger()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `outerEnumDefaultValue` to the URL query string if (getOuterEnumDefaultValue() != null) { try { - joiner.add(String.format("%s[outerEnumDefaultValue]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumDefaultValue()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumDefaultValue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumDefaultValue()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `outerEnumIntegerDefaultValue` to the URL query string if (getOuterEnumIntegerDefaultValue() != null) { try { - joiner.add(String.format("%s[outerEnumIntegerDefaultValue]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumIntegerDefaultValue()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumIntegerDefaultValue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumIntegerDefaultValue()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java index 1aac2884f26..f3f28bbd8d0 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java @@ -146,6 +146,15 @@ public class FileSchemaTestClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -153,22 +162,37 @@ public class FileSchemaTestClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `file` to the URL query string if (getFile() != null) { - joiner.add(getFile().toUrlQueryString(prefix + "[file]")); + joiner.add(getFile().toUrlQueryString(prefix + "file" + suffix)); } + // add `files` to the URL query string if (getFiles() != null) { for (int i = 0; i < getFiles().size(); i++) { if (getFiles().get(i) != null) { - joiner.add(getFiles().get(i).toUrlQueryString(String.format("%s[files][%d]", prefix, i))); + joiner.add(getFiles().get(i).toUrlQueryString(String.format("%sfiles%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Foo.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Foo.java index 5ef461789f4..837f286376b 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Foo.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Foo.java @@ -103,6 +103,15 @@ public class Foo { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -110,19 +119,32 @@ public class Foo { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `bar` to the URL query string if (getBar() != null) { try { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java index 665b8f541fa..24955a1b750 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java @@ -105,6 +105,15 @@ public class FooGetDefaultResponse { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -112,14 +121,27 @@ public class FooGetDefaultResponse { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `string` to the URL query string if (getString() != null) { - joiner.add(getString().toUrlQueryString(prefix + "[string]")); + joiner.add(getString().toUrlQueryString(prefix + "string" + suffix)); } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FormatTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FormatTest.java index f0d6ecaea2a..ccfa16f1dd3 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FormatTest.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/FormatTest.java @@ -599,6 +599,15 @@ public class FormatTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -606,154 +615,182 @@ public class FormatTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `integer` to the URL query string if (getInteger() != null) { try { - joiner.add(String.format("%s[integer]=%s", prefix, URLEncoder.encode(String.valueOf(getInteger()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sinteger%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInteger()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `int32` to the URL query string if (getInt32() != null) { try { - joiner.add(String.format("%s[int32]=%s", prefix, URLEncoder.encode(String.valueOf(getInt32()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sint32%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInt32()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `int64` to the URL query string if (getInt64() != null) { try { - joiner.add(String.format("%s[int64]=%s", prefix, URLEncoder.encode(String.valueOf(getInt64()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sint64%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInt64()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `number` to the URL query string if (getNumber() != null) { try { - joiner.add(String.format("%s[number]=%s", prefix, URLEncoder.encode(String.valueOf(getNumber()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%snumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumber()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `float` to the URL query string if (getFloat() != null) { try { - joiner.add(String.format("%s[float]=%s", prefix, URLEncoder.encode(String.valueOf(getFloat()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfloat%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFloat()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `double` to the URL query string if (getDouble() != null) { try { - joiner.add(String.format("%s[double]=%s", prefix, URLEncoder.encode(String.valueOf(getDouble()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdouble%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDouble()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `decimal` to the URL query string if (getDecimal() != null) { try { - joiner.add(String.format("%s[decimal]=%s", prefix, URLEncoder.encode(String.valueOf(getDecimal()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdecimal%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDecimal()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `string` to the URL query string if (getString() != null) { try { - joiner.add(String.format("%s[string]=%s", prefix, URLEncoder.encode(String.valueOf(getString()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstring%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getString()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `byte` to the URL query string if (getByte() != null) { try { - joiner.add(String.format("%s[byte]=%s", prefix, URLEncoder.encode(String.valueOf(getByte()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbyte%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getByte()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `binary` to the URL query string if (getBinary() != null) { try { - joiner.add(String.format("%s[binary]=%s", prefix, URLEncoder.encode(String.valueOf(getBinary()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbinary%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBinary()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `date` to the URL query string if (getDate() != null) { try { - joiner.add(String.format("%s[date]=%s", prefix, URLEncoder.encode(String.valueOf(getDate()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `dateTime` to the URL query string if (getDateTime() != null) { try { - joiner.add(String.format("%s[dateTime]=%s", prefix, URLEncoder.encode(String.valueOf(getDateTime()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdateTime%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateTime()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `uuid` to the URL query string if (getUuid() != null) { try { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `password` to the URL query string if (getPassword() != null) { try { - joiner.add(String.format("%s[password]=%s", prefix, URLEncoder.encode(String.valueOf(getPassword()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%spassword%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPassword()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `pattern_with_digits` to the URL query string if (getPatternWithDigits() != null) { try { - joiner.add(String.format("%s[pattern_with_digits]=%s", prefix, URLEncoder.encode(String.valueOf(getPatternWithDigits()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%spattern_with_digits%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPatternWithDigits()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `pattern_with_digits_and_delimiter` to the URL query string if (getPatternWithDigitsAndDelimiter() != null) { try { - joiner.add(String.format("%s[pattern_with_digits_and_delimiter]=%s", prefix, URLEncoder.encode(String.valueOf(getPatternWithDigitsAndDelimiter()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%spattern_with_digits_and_delimiter%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPatternWithDigitsAndDelimiter()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java index 7817bae3937..dbfe98898fe 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java @@ -124,6 +124,15 @@ public class HasOnlyReadOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -131,28 +140,42 @@ public class HasOnlyReadOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `bar` to the URL query string if (getBar() != null) { try { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `foo` to the URL query string if (getFoo() != null) { try { - joiner.add(String.format("%s[foo]=%s", prefix, URLEncoder.encode(String.valueOf(getFoo()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfoo%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFoo()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HealthCheckResult.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HealthCheckResult.java index 3fbb2d2cac4..cc0e8b04f4a 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HealthCheckResult.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/HealthCheckResult.java @@ -126,6 +126,15 @@ public class HealthCheckResult { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -133,19 +142,32 @@ public class HealthCheckResult { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `NullableMessage` to the URL query string if (getNullableMessage() != null) { try { - joiner.add(String.format("%s[NullableMessage]=%s", prefix, URLEncoder.encode(String.valueOf(getNullableMessage()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sNullableMessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNullableMessage()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java index bfe6dc90b06..9470661d8fc 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MapTest.java @@ -268,6 +268,15 @@ public class MapTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -275,54 +284,78 @@ public class MapTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `map_map_of_string` to the URL query string if (getMapMapOfString() != null) { for (String _key : getMapMapOfString().keySet()) { try { - joiner.add(String.format("%s[map_map_of_string][%s]=%s", prefix, getMapMapOfString().get(_key), URLEncoder.encode(String.valueOf(getMapMapOfString().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_map_of_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapMapOfString().get(_key), URLEncoder.encode(String.valueOf(getMapMapOfString().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `map_of_enum_string` to the URL query string if (getMapOfEnumString() != null) { for (String _key : getMapOfEnumString().keySet()) { try { - joiner.add(String.format("%s[map_of_enum_string][%s]=%s", prefix, getMapOfEnumString().get(_key), URLEncoder.encode(String.valueOf(getMapOfEnumString().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_of_enum_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapOfEnumString().get(_key), URLEncoder.encode(String.valueOf(getMapOfEnumString().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `direct_map` to the URL query string if (getDirectMap() != null) { for (String _key : getDirectMap().keySet()) { try { - joiner.add(String.format("%s[direct_map][%s]=%s", prefix, getDirectMap().get(_key), URLEncoder.encode(String.valueOf(getDirectMap().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdirect_map%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getDirectMap().get(_key), URLEncoder.encode(String.valueOf(getDirectMap().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `indirect_map` to the URL query string if (getIndirectMap() != null) { for (String _key : getIndirectMap().keySet()) { try { - joiner.add(String.format("%s[indirect_map][%s]=%s", prefix, getIndirectMap().get(_key), URLEncoder.encode(String.valueOf(getIndirectMap().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sindirect_map%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getIndirectMap().get(_key), URLEncoder.encode(String.valueOf(getIndirectMap().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 6112c448059..689701a7d35 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -180,6 +180,15 @@ public class MixedPropertiesAndAdditionalPropertiesClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -187,36 +196,52 @@ public class MixedPropertiesAndAdditionalPropertiesClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `uuid` to the URL query string if (getUuid() != null) { try { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `dateTime` to the URL query string if (getDateTime() != null) { try { - joiner.add(String.format("%s[dateTime]=%s", prefix, URLEncoder.encode(String.valueOf(getDateTime()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdateTime%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateTime()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `map` to the URL query string if (getMap() != null) { for (String _key : getMap().keySet()) { if (getMap().get(_key) != null) { - joiner.add(getMap().get(_key).toUrlQueryString(String.format("%s[map][%s]", prefix, _key))); + joiner.add(getMap().get(_key).toUrlQueryString(String.format("%smap%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Model200Response.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Model200Response.java index 729cf9adaec..b5bc68d4e19 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Model200Response.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Model200Response.java @@ -136,6 +136,15 @@ public class Model200Response { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -143,28 +152,42 @@ public class Model200Response { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `class` to the URL query string if (getPropertyClass() != null) { try { - joiner.add(String.format("%s[class]=%s", prefix, URLEncoder.encode(String.valueOf(getPropertyClass()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclass%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPropertyClass()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelApiResponse.java index c7ed38589a5..0d7a12780e3 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -168,6 +168,15 @@ public class ModelApiResponse { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -175,37 +184,52 @@ public class ModelApiResponse { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `code` to the URL query string if (getCode() != null) { try { - joiner.add(String.format("%s[code]=%s", prefix, URLEncoder.encode(String.valueOf(getCode()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%scode%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCode()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `type` to the URL query string if (getType() != null) { try { - joiner.add(String.format("%s[type]=%s", prefix, URLEncoder.encode(String.valueOf(getType()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `message` to the URL query string if (getMessage() != null) { try { - joiner.add(String.format("%s[message]=%s", prefix, URLEncoder.encode(String.valueOf(getMessage()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMessage()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelFile.java index e42a5aec6a1..e14130a295b 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelFile.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelFile.java @@ -104,6 +104,15 @@ public class ModelFile { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class ModelFile { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `sourceURI` to the URL query string if (getSourceURI() != null) { try { - joiner.add(String.format("%s[sourceURI]=%s", prefix, URLEncoder.encode(String.valueOf(getSourceURI()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssourceURI%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSourceURI()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelList.java index d0a8535aea3..b58f2e168c5 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelList.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelList.java @@ -104,6 +104,15 @@ public class ModelList { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class ModelList { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `123-list` to the URL query string if (get123list() != null) { try { - joiner.add(String.format("%s[123-list]=%s", prefix, URLEncoder.encode(String.valueOf(get123list()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s123-list%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get123list()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelReturn.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelReturn.java index 47c16f20268..1dfb8ee7cf6 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelReturn.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ModelReturn.java @@ -104,6 +104,15 @@ public class ModelReturn { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class ModelReturn { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `return` to the URL query string if (getReturn() != null) { try { - joiner.add(String.format("%s[return]=%s", prefix, URLEncoder.encode(String.valueOf(getReturn()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sreturn%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getReturn()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Name.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Name.java index d3a9dd256ab..4f699a6939f 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Name.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Name.java @@ -187,6 +187,15 @@ public class Name { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -194,46 +203,62 @@ public class Name { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `snake_case` to the URL query string if (getSnakeCase() != null) { try { - joiner.add(String.format("%s[snake_case]=%s", prefix, URLEncoder.encode(String.valueOf(getSnakeCase()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssnake_case%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSnakeCase()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `property` to the URL query string if (getProperty() != null) { try { - joiner.add(String.format("%s[property]=%s", prefix, URLEncoder.encode(String.valueOf(getProperty()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sproperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getProperty()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `123Number` to the URL query string if (get123number() != null) { try { - joiner.add(String.format("%s[123Number]=%s", prefix, URLEncoder.encode(String.valueOf(get123number()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s123Number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get123number()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java index 604f5f9e27d..17de80dbc28 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NullableClass.java @@ -624,6 +624,15 @@ public class NullableClass extends HashMap { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -631,130 +640,166 @@ public class NullableClass extends HashMap { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `integer_prop` to the URL query string if (getIntegerProp() != null) { try { - joiner.add(String.format("%s[integer_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getIntegerProp()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sinteger_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getIntegerProp()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `number_prop` to the URL query string if (getNumberProp() != null) { try { - joiner.add(String.format("%s[number_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getNumberProp()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%snumber_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumberProp()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `boolean_prop` to the URL query string if (getBooleanProp() != null) { try { - joiner.add(String.format("%s[boolean_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getBooleanProp()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sboolean_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBooleanProp()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `string_prop` to the URL query string if (getStringProp() != null) { try { - joiner.add(String.format("%s[string_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getStringProp()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstring_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringProp()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `date_prop` to the URL query string if (getDateProp() != null) { try { - joiner.add(String.format("%s[date_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getDateProp()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdate_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateProp()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `datetime_prop` to the URL query string if (getDatetimeProp() != null) { try { - joiner.add(String.format("%s[datetime_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getDatetimeProp()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdatetime_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDatetimeProp()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `array_nullable_prop` to the URL query string if (getArrayNullableProp() != null) { for (int i = 0; i < getArrayNullableProp().size(); i++) { try { - joiner.add(String.format("%s[array_nullable_prop][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayNullableProp().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayNullableProp().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `array_and_items_nullable_prop` to the URL query string if (getArrayAndItemsNullableProp() != null) { for (int i = 0; i < getArrayAndItemsNullableProp().size(); i++) { try { - joiner.add(String.format("%s[array_and_items_nullable_prop][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayAndItemsNullableProp().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_and_items_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayAndItemsNullableProp().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `array_items_nullable` to the URL query string if (getArrayItemsNullable() != null) { for (int i = 0; i < getArrayItemsNullable().size(); i++) { try { - joiner.add(String.format("%s[array_items_nullable][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayItemsNullable().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_items_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayItemsNullable().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `object_nullable_prop` to the URL query string if (getObjectNullableProp() != null) { for (String _key : getObjectNullableProp().keySet()) { try { - joiner.add(String.format("%s[object_nullable_prop][%s]=%s", prefix, getObjectNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectNullableProp().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectNullableProp().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `object_and_items_nullable_prop` to the URL query string if (getObjectAndItemsNullableProp() != null) { for (String _key : getObjectAndItemsNullableProp().keySet()) { try { - joiner.add(String.format("%s[object_and_items_nullable_prop][%s]=%s", prefix, getObjectAndItemsNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectAndItemsNullableProp().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_and_items_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectAndItemsNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectAndItemsNullableProp().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + // add `object_items_nullable` to the URL query string if (getObjectItemsNullable() != null) { for (String _key : getObjectItemsNullable().keySet()) { try { - joiner.add(String.format("%s[object_items_nullable][%s]=%s", prefix, getObjectItemsNullable().get(_key), URLEncoder.encode(String.valueOf(getObjectItemsNullable().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_items_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectItemsNullable().get(_key), URLEncoder.encode(String.valueOf(getObjectItemsNullable().get(_key)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NumberOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NumberOnly.java index 25141ccc633..1e08e1f7c06 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NumberOnly.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/NumberOnly.java @@ -104,6 +104,15 @@ public class NumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class NumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `JustNumber` to the URL query string if (getJustNumber() != null) { try { - joiner.add(String.format("%s[JustNumber]=%s", prefix, URLEncoder.encode(String.valueOf(getJustNumber()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sJustNumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getJustNumber()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java index 6b815e639ab..eb1966fc5db 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java @@ -217,6 +217,15 @@ public class ObjectWithDeprecatedFields { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -224,43 +233,61 @@ public class ObjectWithDeprecatedFields { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `uuid` to the URL query string if (getUuid() != null) { try { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `deprecatedRef` to the URL query string if (getDeprecatedRef() != null) { - joiner.add(getDeprecatedRef().toUrlQueryString(prefix + "[deprecatedRef]")); + joiner.add(getDeprecatedRef().toUrlQueryString(prefix + "deprecatedRef" + suffix)); } + // add `bars` to the URL query string if (getBars() != null) { for (int i = 0; i < getBars().size(); i++) { try { - joiner.add(String.format("%s[bars][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getBars().get(i)), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbars%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getBars().get(i)), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Order.java index 7619ef6103d..013f8c3e049 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Order.java @@ -301,6 +301,15 @@ public class Order { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -308,64 +317,82 @@ public class Order { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `petId` to the URL query string if (getPetId() != null) { try { - joiner.add(String.format("%s[petId]=%s", prefix, URLEncoder.encode(String.valueOf(getPetId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%spetId%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPetId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `quantity` to the URL query string if (getQuantity() != null) { try { - joiner.add(String.format("%s[quantity]=%s", prefix, URLEncoder.encode(String.valueOf(getQuantity()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%squantity%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getQuantity()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `shipDate` to the URL query string if (getShipDate() != null) { try { - joiner.add(String.format("%s[shipDate]=%s", prefix, URLEncoder.encode(String.valueOf(getShipDate()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getShipDate()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `status` to the URL query string if (getStatus() != null) { try { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `complete` to the URL query string if (getComplete() != null) { try { - joiner.add(String.format("%s[complete]=%s", prefix, URLEncoder.encode(String.valueOf(getComplete()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getComplete()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterComposite.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterComposite.java index 72f76ff87ea..2259dfcaacf 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterComposite.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterComposite.java @@ -168,6 +168,15 @@ public class OuterComposite { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -175,37 +184,52 @@ public class OuterComposite { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `my_number` to the URL query string if (getMyNumber() != null) { try { - joiner.add(String.format("%s[my_number]=%s", prefix, URLEncoder.encode(String.valueOf(getMyNumber()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyNumber()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `my_string` to the URL query string if (getMyString() != null) { try { - joiner.add(String.format("%s[my_string]=%s", prefix, URLEncoder.encode(String.valueOf(getMyString()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_string%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyString()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `my_boolean` to the URL query string if (getMyBoolean() != null) { try { - joiner.add(String.format("%s[my_boolean]=%s", prefix, URLEncoder.encode(String.valueOf(getMyBoolean()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_boolean%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyBoolean()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java index 0e5ef5e2cef..737d1c245d3 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java @@ -104,6 +104,15 @@ public class OuterObjectWithEnumProperty { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class OuterObjectWithEnumProperty { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `value` to the URL query string if (getValue() != null) { try { - joiner.add(String.format("%s[value]=%s", prefix, URLEncoder.encode(String.valueOf(getValue()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%svalue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getValue()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java index 80dc9fa3163..23b6d160ed2 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Pet.java @@ -321,6 +321,15 @@ public class Pet { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -328,38 +337,55 @@ public class Pet { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `category` to the URL query string if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "[category]")); + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); } + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `photoUrls` to the URL query string if (getPhotoUrls() != null) { int i = 0; for (String _item : getPhotoUrls()) { try { - joiner.add(String.format("%s[photoUrls][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(_item), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); @@ -367,23 +393,27 @@ public class Pet { } i++; } + // add `tags` to the URL query string if (getTags() != null) { for (int i = 0; i < getTags().size(); i++) { if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%s[tags][%d]", prefix, i))); + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } + // add `status` to the URL query string if (getStatus() != null) { try { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java index 10cab3b31a6..0516626bab1 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java @@ -132,6 +132,15 @@ public class ReadOnlyFirst { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -139,28 +148,42 @@ public class ReadOnlyFirst { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `bar` to the URL query string if (getBar() != null) { try { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `baz` to the URL query string if (getBaz() != null) { try { - joiner.add(String.format("%s[baz]=%s", prefix, URLEncoder.encode(String.valueOf(getBaz()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbaz%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBaz()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/SpecialModelName.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/SpecialModelName.java index 044f339c5b7..8783277244d 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/SpecialModelName.java @@ -104,6 +104,15 @@ public class SpecialModelName { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -111,19 +120,32 @@ public class SpecialModelName { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `$special[property.name]` to the URL query string if (get$SpecialPropertyName() != null) { try { - joiner.add(String.format("%s[$special[property.name]]=%s", prefix, URLEncoder.encode(String.valueOf(get$SpecialPropertyName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%s$special[property.name]%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get$SpecialPropertyName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java index 42ac6b285fb..b31d271ffbf 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/Tag.java @@ -135,6 +135,15 @@ public class Tag { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -142,28 +151,42 @@ public class Tag { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `name` to the URL query string if (getName() != null) { try { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/User.java index 719ceb671ab..ad9710c2340 100644 --- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/User.java @@ -327,6 +327,15 @@ public class User { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -334,82 +343,102 @@ public class User { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } + StringJoiner joiner = new StringJoiner("&"); + // add `id` to the URL query string if (getId() != null) { try { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `username` to the URL query string if (getUsername() != null) { try { - joiner.add(String.format("%s[username]=%s", prefix, URLEncoder.encode(String.valueOf(getUsername()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%susername%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUsername()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `firstName` to the URL query string if (getFirstName() != null) { try { - joiner.add(String.format("%s[firstName]=%s", prefix, URLEncoder.encode(String.valueOf(getFirstName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFirstName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `lastName` to the URL query string if (getLastName() != null) { try { - joiner.add(String.format("%s[lastName]=%s", prefix, URLEncoder.encode(String.valueOf(getLastName()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%slastName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getLastName()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `email` to the URL query string if (getEmail() != null) { try { - joiner.add(String.format("%s[email]=%s", prefix, URLEncoder.encode(String.valueOf(getEmail()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEmail()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `password` to the URL query string if (getPassword() != null) { try { - joiner.add(String.format("%s[password]=%s", prefix, URLEncoder.encode(String.valueOf(getPassword()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%spassword%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPassword()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `phone` to the URL query string if (getPhone() != null) { try { - joiner.add(String.format("%s[phone]=%s", prefix, URLEncoder.encode(String.valueOf(getPhone()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphone%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPhone()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + // add `userStatus` to the URL query string if (getUserStatus() != null) { try { - joiner.add(String.format("%s[userStatus]=%s", prefix, URLEncoder.encode(String.valueOf(getUserStatus()), "UTF-8").replaceAll("\\+", "%20"))); + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUserStatus()), "UTF-8").replaceAll("\\+", "%20"))); } catch (UnsupportedEncodingException e) { // Should never happen, UTF-8 is always supported throw new RuntimeException(e); } } + return joiner.toString(); } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java index f03332c0f7e..acbab5234f5 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/FakeApi.java @@ -241,16 +241,16 @@ public class FakeApi { String localVarPath = "/fake/http-signature-test"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query_1"; localVarQueryParams.addAll(ApiClient.parameterToPairs("query_1", query1)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -983,16 +983,16 @@ public class FakeApi { String localVarPath = "/fake/body-with-query-params"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query"; localVarQueryParams.addAll(ApiClient.parameterToPairs("query", query)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -1306,7 +1306,7 @@ public class FakeApi { String localVarPath = "/fake"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "enum_query_string_array"; localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "enum_query_string_array", enumQueryStringArray)); @@ -1319,11 +1319,11 @@ public class FakeApi { localVarQueryParameterBaseName = "enum_query_model_array"; localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "enum_query_model_array", enumQueryModelArray)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -1464,7 +1464,7 @@ public class FakeApi { String localVarPath = "/fake"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "required_string_group"; localVarQueryParams.addAll(ApiClient.parameterToPairs("required_string_group", requiredStringGroup)); @@ -1475,11 +1475,11 @@ public class FakeApi { localVarQueryParameterBaseName = "int64_group"; localVarQueryParams.addAll(ApiClient.parameterToPairs("int64_group", int64Group)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -1843,7 +1843,7 @@ public class FakeApi { String localVarPath = "/fake/test-query-parameters"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "pipe"; localVarQueryParams.addAll(ApiClient.parameterToPairs("pipes", "pipe", pipe)); @@ -1860,11 +1860,11 @@ public class FakeApi { localVarQueryParameterBaseName = "allowEmpty"; localVarQueryParams.addAll(ApiClient.parameterToPairs("allowEmpty", allowEmpty)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java index 57eac50166c..3af1861a171 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/PetApi.java @@ -324,16 +324,16 @@ public class PetApi { String localVarPath = "/pet/findByStatus"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "status"; localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -435,16 +435,16 @@ public class PetApi { String localVarPath = "/pet/findByTags"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "tags"; localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java index 0ccc38aa64e..6a56659b2a6 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/api/UserApi.java @@ -582,18 +582,18 @@ public class UserApi { String localVarPath = "/user/login"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "username"; localVarQueryParams.addAll(ApiClient.parameterToPairs("username", username)); localVarQueryParameterBaseName = "password"; localVarQueryParams.addAll(ApiClient.parameterToPairs("password", password)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java index d2cedf566a1..b108c42adcb 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java @@ -156,6 +156,15 @@ public class AdditionalPropertiesClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -163,8 +172,18 @@ public class AdditionalPropertiesClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -172,14 +191,18 @@ public class AdditionalPropertiesClass { // add `map_property` to the URL query string if (getMapProperty() != null) { for (String _key : getMapProperty().keySet()) { - joiner.add(String.format("%s[map_property][%s]=%s", prefix, getMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_property%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `map_of_map_property` to the URL query string if (getMapOfMapProperty() != null) { for (String _key : getMapOfMapProperty().keySet()) { - joiner.add(String.format("%s[map_of_map_property][%s]=%s", prefix, getMapOfMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapOfMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_of_map_property%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapOfMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapOfMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java index d6327307bc8..106abac0919 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java @@ -139,6 +139,15 @@ public class AllOfWithSingleRef { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -146,20 +155,30 @@ public class AllOfWithSingleRef { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `username` to the URL query string if (getUsername() != null) { - joiner.add(String.format("%s[username]=%s", prefix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%susername%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `SingleRefType` to the URL query string if (getSingleRefType() != null) { - joiner.add(getSingleRefType().toUrlQueryString(prefix + "[SingleRefType]")); + joiner.add(getSingleRefType().toUrlQueryString(prefix + "SingleRefType" + suffix)); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Animal.java index 41f93d333f3..cffa1c6286a 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Animal.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Animal.java @@ -154,6 +154,15 @@ public class Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -161,20 +170,30 @@ public class Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `className` to the URL query string if (getClassName() != null) { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java index 25e3a70ae89..43ab3107a49 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java @@ -118,6 +118,15 @@ public class ArrayOfArrayOfNumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -125,8 +134,18 @@ public class ArrayOfArrayOfNumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -135,7 +154,9 @@ public class ArrayOfArrayOfNumberOnly { if (getArrayArrayNumber() != null) { for (int i = 0; i < getArrayArrayNumber().size(); i++) { if (getArrayArrayNumber().get(i) != null) { - joiner.add(String.format("%s[ArrayArrayNumber][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java index f21d71947b4..efa4b6f5c3b 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java @@ -118,6 +118,15 @@ public class ArrayOfNumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -125,8 +134,18 @@ public class ArrayOfNumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -135,7 +154,9 @@ public class ArrayOfNumberOnly { if (getArrayNumber() != null) { for (int i = 0; i < getArrayNumber().size(); i++) { if (getArrayNumber().get(i) != null) { - joiner.add(String.format("%s[ArrayNumber][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayTest.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayTest.java index ef82d407e11..0823c886177 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayTest.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayTest.java @@ -196,6 +196,15 @@ public class ArrayTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -203,8 +212,18 @@ public class ArrayTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -212,14 +231,18 @@ public class ArrayTest { // add `array_of_string` to the URL query string if (getArrayOfString() != null) { for (int i = 0; i < getArrayOfString().size(); i++) { - joiner.add(String.format("%s[array_of_string][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayOfString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_of_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayOfString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `array_array_of_integer` to the URL query string if (getArrayArrayOfInteger() != null) { for (int i = 0; i < getArrayArrayOfInteger().size(); i++) { - joiner.add(String.format("%s[array_array_of_integer][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayOfInteger().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_array_of_integer%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayOfInteger().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } @@ -227,7 +250,9 @@ public class ArrayTest { if (getArrayArrayOfModel() != null) { for (int i = 0; i < getArrayArrayOfModel().size(); i++) { if (getArrayArrayOfModel().get(i) != null) { - joiner.add(String.format("%s[array_array_of_model][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayOfModel().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_array_of_model%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayOfModel().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Capitalization.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Capitalization.java index 86d5b3ac1c5..66035b10d5d 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Capitalization.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Capitalization.java @@ -262,6 +262,15 @@ public class Capitalization { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -269,40 +278,50 @@ public class Capitalization { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `smallCamel` to the URL query string if (getSmallCamel() != null) { - joiner.add(String.format("%s[smallCamel]=%s", prefix, URLEncoder.encode(String.valueOf(getSmallCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssmallCamel%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSmallCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `CapitalCamel` to the URL query string if (getCapitalCamel() != null) { - joiner.add(String.format("%s[CapitalCamel]=%s", prefix, URLEncoder.encode(String.valueOf(getCapitalCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sCapitalCamel%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCapitalCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `small_Snake` to the URL query string if (getSmallSnake() != null) { - joiner.add(String.format("%s[small_Snake]=%s", prefix, URLEncoder.encode(String.valueOf(getSmallSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssmall_Snake%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSmallSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `Capital_Snake` to the URL query string if (getCapitalSnake() != null) { - joiner.add(String.format("%s[Capital_Snake]=%s", prefix, URLEncoder.encode(String.valueOf(getCapitalSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sCapital_Snake%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCapitalSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `SCA_ETH_Flow_Points` to the URL query string if (getScAETHFlowPoints() != null) { - joiner.add(String.format("%s[SCA_ETH_Flow_Points]=%s", prefix, URLEncoder.encode(String.valueOf(getScAETHFlowPoints()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sSCA_ETH_Flow_Points%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getScAETHFlowPoints()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `ATT_NAME` to the URL query string if (getATTNAME() != null) { - joiner.add(String.format("%s[ATT_NAME]=%s", prefix, URLEncoder.encode(String.valueOf(getATTNAME()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sATT_NAME%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getATTNAME()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Cat.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Cat.java index 9b38295c889..8b85a7bb108 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Cat.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Cat.java @@ -120,6 +120,15 @@ public class Cat extends Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -127,25 +136,35 @@ public class Cat extends Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `className` to the URL query string if (getClassName() != null) { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `declawed` to the URL query string if (getDeclawed() != null) { - joiner.add(String.format("%s[declawed]=%s", prefix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdeclawed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/CatAllOf.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/CatAllOf.java index d0e93852876..488de1e892e 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/CatAllOf.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/CatAllOf.java @@ -107,6 +107,15 @@ public class CatAllOf { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class CatAllOf { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `declawed` to the URL query string if (getDeclawed() != null) { - joiner.add(String.format("%s[declawed]=%s", prefix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdeclawed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Category.java index f1c2fe8cf3c..3a31ec85e86 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Category.java @@ -138,6 +138,15 @@ public class Category { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Category { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ClassModel.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ClassModel.java index fa22b8dbd50..b0f7a754c33 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ClassModel.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ClassModel.java @@ -107,6 +107,15 @@ public class ClassModel { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ClassModel { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `_class` to the URL query string if (getPropertyClass() != null) { - joiner.add(String.format("%s[_class]=%s", prefix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s_class%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Client.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Client.java index 2845ad7612b..a6b6b93f0c8 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Client.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Client.java @@ -107,6 +107,15 @@ public class Client { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class Client { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `client` to the URL query string if (getClient() != null) { - joiner.add(String.format("%s[client]=%s", prefix, URLEncoder.encode(String.valueOf(getClient()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclient%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClient()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DeprecatedObject.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DeprecatedObject.java index 938c3ad013f..54d427bcf97 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DeprecatedObject.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -109,6 +109,15 @@ public class DeprecatedObject { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -116,15 +125,25 @@ public class DeprecatedObject { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Dog.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Dog.java index 67fe2c689ab..e46cae8e00e 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Dog.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Dog.java @@ -120,6 +120,15 @@ public class Dog extends Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -127,25 +136,35 @@ public class Dog extends Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `className` to the URL query string if (getClassName() != null) { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `breed` to the URL query string if (getBreed() != null) { - joiner.add(String.format("%s[breed]=%s", prefix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbreed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DogAllOf.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DogAllOf.java index 51a30fdb2a1..82d93902a71 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DogAllOf.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/DogAllOf.java @@ -107,6 +107,15 @@ public class DogAllOf { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class DogAllOf { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `breed` to the URL query string if (getBreed() != null) { - joiner.add(String.format("%s[breed]=%s", prefix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbreed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumArrays.java index 6f79cb8ffb4..ce493352a36 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -218,6 +218,15 @@ public class EnumArrays { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -225,21 +234,33 @@ public class EnumArrays { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `just_symbol` to the URL query string if (getJustSymbol() != null) { - joiner.add(String.format("%s[just_symbol]=%s", prefix, URLEncoder.encode(String.valueOf(getJustSymbol()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sjust_symbol%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getJustSymbol()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `array_enum` to the URL query string if (getArrayEnum() != null) { for (int i = 0; i < getArrayEnum().size(); i++) { - joiner.add(String.format("%s[array_enum][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayEnum().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_enum%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayEnum().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java index c364f9ec024..a7145b32bcb 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/EnumTest.java @@ -495,6 +495,15 @@ public class EnumTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -502,50 +511,60 @@ public class EnumTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `enum_string` to the URL query string if (getEnumString() != null) { - joiner.add(String.format("%s[enum_string]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_string%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `enum_string_required` to the URL query string if (getEnumStringRequired() != null) { - joiner.add(String.format("%s[enum_string_required]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumStringRequired()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_string_required%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumStringRequired()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `enum_integer` to the URL query string if (getEnumInteger() != null) { - joiner.add(String.format("%s[enum_integer]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_integer%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `enum_number` to the URL query string if (getEnumNumber() != null) { - joiner.add(String.format("%s[enum_number]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnum` to the URL query string if (getOuterEnum() != null) { - joiner.add(String.format("%s[outerEnum]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnum()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnum%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnum()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnumInteger` to the URL query string if (getOuterEnumInteger() != null) { - joiner.add(String.format("%s[outerEnumInteger]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumInteger%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnumDefaultValue` to the URL query string if (getOuterEnumDefaultValue() != null) { - joiner.add(String.format("%s[outerEnumDefaultValue]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumDefaultValue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnumIntegerDefaultValue` to the URL query string if (getOuterEnumIntegerDefaultValue() != null) { - joiner.add(String.format("%s[outerEnumIntegerDefaultValue]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumIntegerDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumIntegerDefaultValue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumIntegerDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java index 80cf3a96d69..69f36a8b0fd 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java @@ -149,6 +149,15 @@ public class FileSchemaTestClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -156,22 +165,33 @@ public class FileSchemaTestClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `file` to the URL query string if (getFile() != null) { - joiner.add(getFile().toUrlQueryString(prefix + "[file]")); + joiner.add(getFile().toUrlQueryString(prefix + "file" + suffix)); } // add `files` to the URL query string if (getFiles() != null) { for (int i = 0; i < getFiles().size(); i++) { if (getFiles().get(i) != null) { - joiner.add(getFiles().get(i).toUrlQueryString(String.format("%s[files][%d]", prefix, i))); + joiner.add(getFiles().get(i).toUrlQueryString(String.format("%sfiles%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Foo.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Foo.java index ba27aba5738..1d4de25f317 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Foo.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Foo.java @@ -107,6 +107,15 @@ public class Foo { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class Foo { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `bar` to the URL query string if (getBar() != null) { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java index d9926e3ad37..e978aaf2ee2 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java @@ -108,6 +108,15 @@ public class FooGetDefaultResponse { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -115,15 +124,25 @@ public class FooGetDefaultResponse { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `string` to the URL query string if (getString() != null) { - joiner.add(getString().toUrlQueryString(prefix + "[string]")); + joiner.add(getString().toUrlQueryString(prefix + "string" + suffix)); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FormatTest.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FormatTest.java index e65ec569af3..478fbb634c5 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FormatTest.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/FormatTest.java @@ -587,6 +587,15 @@ public class FormatTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -594,90 +603,100 @@ public class FormatTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `integer` to the URL query string if (getInteger() != null) { - joiner.add(String.format("%s[integer]=%s", prefix, URLEncoder.encode(String.valueOf(getInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sinteger%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `int32` to the URL query string if (getInt32() != null) { - joiner.add(String.format("%s[int32]=%s", prefix, URLEncoder.encode(String.valueOf(getInt32()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sint32%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInt32()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `int64` to the URL query string if (getInt64() != null) { - joiner.add(String.format("%s[int64]=%s", prefix, URLEncoder.encode(String.valueOf(getInt64()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sint64%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInt64()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `number` to the URL query string if (getNumber() != null) { - joiner.add(String.format("%s[number]=%s", prefix, URLEncoder.encode(String.valueOf(getNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%snumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `float` to the URL query string if (getFloat() != null) { - joiner.add(String.format("%s[float]=%s", prefix, URLEncoder.encode(String.valueOf(getFloat()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfloat%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFloat()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `double` to the URL query string if (getDouble() != null) { - joiner.add(String.format("%s[double]=%s", prefix, URLEncoder.encode(String.valueOf(getDouble()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdouble%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDouble()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `decimal` to the URL query string if (getDecimal() != null) { - joiner.add(String.format("%s[decimal]=%s", prefix, URLEncoder.encode(String.valueOf(getDecimal()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdecimal%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDecimal()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `string` to the URL query string if (getString() != null) { - joiner.add(String.format("%s[string]=%s", prefix, URLEncoder.encode(String.valueOf(getString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstring%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `byte` to the URL query string if (getByte() != null) { - joiner.add(String.format("%s[byte]=%s", prefix, URLEncoder.encode(String.valueOf(getByte()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbyte%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getByte()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `binary` to the URL query string if (getBinary() != null) { - joiner.add(String.format("%s[binary]=%s", prefix, URLEncoder.encode(String.valueOf(getBinary()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbinary%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBinary()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `date` to the URL query string if (getDate() != null) { - joiner.add(String.format("%s[date]=%s", prefix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `dateTime` to the URL query string if (getDateTime() != null) { - joiner.add(String.format("%s[dateTime]=%s", prefix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdateTime%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `uuid` to the URL query string if (getUuid() != null) { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `password` to the URL query string if (getPassword() != null) { - joiner.add(String.format("%s[password]=%s", prefix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spassword%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `pattern_with_digits` to the URL query string if (getPatternWithDigits() != null) { - joiner.add(String.format("%s[pattern_with_digits]=%s", prefix, URLEncoder.encode(String.valueOf(getPatternWithDigits()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spattern_with_digits%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPatternWithDigits()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `pattern_with_digits_and_delimiter` to the URL query string if (getPatternWithDigitsAndDelimiter() != null) { - joiner.add(String.format("%s[pattern_with_digits_and_delimiter]=%s", prefix, URLEncoder.encode(String.valueOf(getPatternWithDigitsAndDelimiter()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spattern_with_digits_and_delimiter%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPatternWithDigitsAndDelimiter()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java index 9081d5e8031..f6c4d6a7eb5 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java @@ -128,6 +128,15 @@ public class HasOnlyReadOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -135,20 +144,30 @@ public class HasOnlyReadOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `bar` to the URL query string if (getBar() != null) { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `foo` to the URL query string if (getFoo() != null) { - joiner.add(String.format("%s[foo]=%s", prefix, URLEncoder.encode(String.valueOf(getFoo()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfoo%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFoo()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HealthCheckResult.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HealthCheckResult.java index 4b8c287d70b..51e41ec085c 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HealthCheckResult.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/HealthCheckResult.java @@ -130,6 +130,15 @@ public class HealthCheckResult { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -137,15 +146,25 @@ public class HealthCheckResult { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `NullableMessage` to the URL query string if (getNullableMessage() != null) { - joiner.add(String.format("%s[NullableMessage]=%s", prefix, URLEncoder.encode(String.valueOf(getNullableMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sNullableMessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNullableMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MapTest.java index c04f87b0aef..f917d0265d0 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MapTest.java @@ -269,6 +269,15 @@ public class MapTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -276,8 +285,18 @@ public class MapTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -285,28 +304,36 @@ public class MapTest { // add `map_map_of_string` to the URL query string if (getMapMapOfString() != null) { for (String _key : getMapMapOfString().keySet()) { - joiner.add(String.format("%s[map_map_of_string][%s]=%s", prefix, getMapMapOfString().get(_key), URLEncoder.encode(String.valueOf(getMapMapOfString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_map_of_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapMapOfString().get(_key), URLEncoder.encode(String.valueOf(getMapMapOfString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `map_of_enum_string` to the URL query string if (getMapOfEnumString() != null) { for (String _key : getMapOfEnumString().keySet()) { - joiner.add(String.format("%s[map_of_enum_string][%s]=%s", prefix, getMapOfEnumString().get(_key), URLEncoder.encode(String.valueOf(getMapOfEnumString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_of_enum_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapOfEnumString().get(_key), URLEncoder.encode(String.valueOf(getMapOfEnumString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `direct_map` to the URL query string if (getDirectMap() != null) { for (String _key : getDirectMap().keySet()) { - joiner.add(String.format("%s[direct_map][%s]=%s", prefix, getDirectMap().get(_key), URLEncoder.encode(String.valueOf(getDirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdirect_map%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getDirectMap().get(_key), URLEncoder.encode(String.valueOf(getDirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `indirect_map` to the URL query string if (getIndirectMap() != null) { for (String _key : getIndirectMap().keySet()) { - joiner.add(String.format("%s[indirect_map][%s]=%s", prefix, getIndirectMap().get(_key), URLEncoder.encode(String.valueOf(getIndirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sindirect_map%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getIndirectMap().get(_key), URLEncoder.encode(String.valueOf(getIndirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index c5b248d25cd..fe0b0e67c5f 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -182,6 +182,15 @@ public class MixedPropertiesAndAdditionalPropertiesClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -189,27 +198,38 @@ public class MixedPropertiesAndAdditionalPropertiesClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `uuid` to the URL query string if (getUuid() != null) { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `dateTime` to the URL query string if (getDateTime() != null) { - joiner.add(String.format("%s[dateTime]=%s", prefix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdateTime%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `map` to the URL query string if (getMap() != null) { for (String _key : getMap().keySet()) { if (getMap().get(_key) != null) { - joiner.add(getMap().get(_key).toUrlQueryString(String.format("%s[map][%s]", prefix, _key))); + joiner.add(getMap().get(_key).toUrlQueryString(String.format("%smap%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); } } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Model200Response.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Model200Response.java index 5fe66d61034..15c576c91da 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Model200Response.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Model200Response.java @@ -138,6 +138,15 @@ public class Model200Response { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Model200Response { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `class` to the URL query string if (getPropertyClass() != null) { - joiner.add(String.format("%s[class]=%s", prefix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclass%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelApiResponse.java index 0fda9e67141..6f74d3ca962 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -169,6 +169,15 @@ public class ModelApiResponse { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -176,25 +185,35 @@ public class ModelApiResponse { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `code` to the URL query string if (getCode() != null) { - joiner.add(String.format("%s[code]=%s", prefix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scode%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `type` to the URL query string if (getType() != null) { - joiner.add(String.format("%s[type]=%s", prefix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `message` to the URL query string if (getMessage() != null) { - joiner.add(String.format("%s[message]=%s", prefix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelFile.java index 149d2288e00..61ada7082fd 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelFile.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelFile.java @@ -107,6 +107,15 @@ public class ModelFile { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ModelFile { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `sourceURI` to the URL query string if (getSourceURI() != null) { - joiner.add(String.format("%s[sourceURI]=%s", prefix, URLEncoder.encode(String.valueOf(getSourceURI()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssourceURI%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSourceURI()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelList.java index 379d7c63c61..7e3e24c2d68 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelList.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelList.java @@ -107,6 +107,15 @@ public class ModelList { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ModelList { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `123-list` to the URL query string if (get123list() != null) { - joiner.add(String.format("%s[123-list]=%s", prefix, URLEncoder.encode(String.valueOf(get123list()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s123-list%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get123list()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelReturn.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelReturn.java index b3ad4492698..8c442eaeef1 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelReturn.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ModelReturn.java @@ -107,6 +107,15 @@ public class ModelReturn { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ModelReturn { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `return` to the URL query string if (getReturn() != null) { - joiner.add(String.format("%s[return]=%s", prefix, URLEncoder.encode(String.valueOf(getReturn()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sreturn%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getReturn()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Name.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Name.java index 13e43af8c2e..ae795ee5c5d 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Name.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Name.java @@ -190,6 +190,15 @@ public class Name { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -197,30 +206,40 @@ public class Name { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `snake_case` to the URL query string if (getSnakeCase() != null) { - joiner.add(String.format("%s[snake_case]=%s", prefix, URLEncoder.encode(String.valueOf(getSnakeCase()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssnake_case%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSnakeCase()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `property` to the URL query string if (getProperty() != null) { - joiner.add(String.format("%s[property]=%s", prefix, URLEncoder.encode(String.valueOf(getProperty()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sproperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getProperty()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `123Number` to the URL query string if (get123number() != null) { - joiner.add(String.format("%s[123Number]=%s", prefix, URLEncoder.encode(String.valueOf(get123number()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s123Number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get123number()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java index 9877503e43c..9b541d23092 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NullableClass.java @@ -665,6 +665,15 @@ public class NullableClass extends HashMap { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -672,81 +681,103 @@ public class NullableClass extends HashMap { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `integer_prop` to the URL query string if (getIntegerProp() != null) { - joiner.add(String.format("%s[integer_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getIntegerProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sinteger_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getIntegerProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `number_prop` to the URL query string if (getNumberProp() != null) { - joiner.add(String.format("%s[number_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getNumberProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%snumber_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumberProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `boolean_prop` to the URL query string if (getBooleanProp() != null) { - joiner.add(String.format("%s[boolean_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getBooleanProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sboolean_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBooleanProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `string_prop` to the URL query string if (getStringProp() != null) { - joiner.add(String.format("%s[string_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getStringProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstring_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `date_prop` to the URL query string if (getDateProp() != null) { - joiner.add(String.format("%s[date_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getDateProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdate_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `datetime_prop` to the URL query string if (getDatetimeProp() != null) { - joiner.add(String.format("%s[datetime_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getDatetimeProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdatetime_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDatetimeProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `array_nullable_prop` to the URL query string if (getArrayNullableProp() != null) { for (int i = 0; i < getArrayNullableProp().size(); i++) { - joiner.add(String.format("%s[array_nullable_prop][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `array_and_items_nullable_prop` to the URL query string if (getArrayAndItemsNullableProp() != null) { for (int i = 0; i < getArrayAndItemsNullableProp().size(); i++) { - joiner.add(String.format("%s[array_and_items_nullable_prop][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayAndItemsNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_and_items_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayAndItemsNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `array_items_nullable` to the URL query string if (getArrayItemsNullable() != null) { for (int i = 0; i < getArrayItemsNullable().size(); i++) { - joiner.add(String.format("%s[array_items_nullable][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayItemsNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_items_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayItemsNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `object_nullable_prop` to the URL query string if (getObjectNullableProp() != null) { for (String _key : getObjectNullableProp().keySet()) { - joiner.add(String.format("%s[object_nullable_prop][%s]=%s", prefix, getObjectNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `object_and_items_nullable_prop` to the URL query string if (getObjectAndItemsNullableProp() != null) { for (String _key : getObjectAndItemsNullableProp().keySet()) { - joiner.add(String.format("%s[object_and_items_nullable_prop][%s]=%s", prefix, getObjectAndItemsNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectAndItemsNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_and_items_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectAndItemsNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectAndItemsNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `object_items_nullable` to the URL query string if (getObjectItemsNullable() != null) { for (String _key : getObjectItemsNullable().keySet()) { - joiner.add(String.format("%s[object_items_nullable][%s]=%s", prefix, getObjectItemsNullable().get(_key), URLEncoder.encode(String.valueOf(getObjectItemsNullable().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_items_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectItemsNullable().get(_key), URLEncoder.encode(String.valueOf(getObjectItemsNullable().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NumberOnly.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NumberOnly.java index bcde8140bd8..55e6fb71822 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NumberOnly.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/NumberOnly.java @@ -108,6 +108,15 @@ public class NumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -115,15 +124,25 @@ public class NumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `JustNumber` to the URL query string if (getJustNumber() != null) { - joiner.add(String.format("%s[JustNumber]=%s", prefix, URLEncoder.encode(String.valueOf(getJustNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sJustNumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getJustNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java index 1c2be218ce3..461b96adb1e 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java @@ -218,6 +218,15 @@ public class ObjectWithDeprecatedFields { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -225,31 +234,43 @@ public class ObjectWithDeprecatedFields { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `uuid` to the URL query string if (getUuid() != null) { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `deprecatedRef` to the URL query string if (getDeprecatedRef() != null) { - joiner.add(getDeprecatedRef().toUrlQueryString(prefix + "[deprecatedRef]")); + joiner.add(getDeprecatedRef().toUrlQueryString(prefix + "deprecatedRef" + suffix)); } // add `bars` to the URL query string if (getBars() != null) { for (int i = 0; i < getBars().size(); i++) { - joiner.add(String.format("%s[bars][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getBars().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbars%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getBars().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Order.java index 3f5c901bdbf..687b6b80ea3 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Order.java @@ -300,6 +300,15 @@ public class Order { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -307,40 +316,50 @@ public class Order { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `petId` to the URL query string if (getPetId() != null) { - joiner.add(String.format("%s[petId]=%s", prefix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spetId%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `quantity` to the URL query string if (getQuantity() != null) { - joiner.add(String.format("%s[quantity]=%s", prefix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%squantity%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `shipDate` to the URL query string if (getShipDate() != null) { - joiner.add(String.format("%s[shipDate]=%s", prefix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `status` to the URL query string if (getStatus() != null) { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `complete` to the URL query string if (getComplete() != null) { - joiner.add(String.format("%s[complete]=%s", prefix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterComposite.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterComposite.java index 13c55053ef6..d07b2ad8c78 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterComposite.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterComposite.java @@ -170,6 +170,15 @@ public class OuterComposite { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -177,25 +186,35 @@ public class OuterComposite { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `my_number` to the URL query string if (getMyNumber() != null) { - joiner.add(String.format("%s[my_number]=%s", prefix, URLEncoder.encode(String.valueOf(getMyNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `my_string` to the URL query string if (getMyString() != null) { - joiner.add(String.format("%s[my_string]=%s", prefix, URLEncoder.encode(String.valueOf(getMyString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_string%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `my_boolean` to the URL query string if (getMyBoolean() != null) { - joiner.add(String.format("%s[my_boolean]=%s", prefix, URLEncoder.encode(String.valueOf(getMyBoolean()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_boolean%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyBoolean()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java index 1f5e24849c4..f19ffcca8af 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java @@ -108,6 +108,15 @@ public class OuterObjectWithEnumProperty { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -115,15 +124,25 @@ public class OuterObjectWithEnumProperty { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `value` to the URL query string if (getValue() != null) { - joiner.add(String.format("%s[value]=%s", prefix, URLEncoder.encode(String.valueOf(getValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%svalue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Pet.java index a022ceb3238..3aae87e766e 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Pet.java @@ -320,6 +320,15 @@ public class Pet { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -327,32 +336,44 @@ public class Pet { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `category` to the URL query string if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "[category]")); + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `photoUrls` to the URL query string if (getPhotoUrls() != null) { int i = 0; for (String _item : getPhotoUrls()) { - joiner.add(String.format("%s[photoUrls][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } i++; } @@ -361,14 +382,15 @@ public class Pet { if (getTags() != null) { for (int i = 0; i < getTags().size(); i++) { if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%s[tags][%d]", prefix, i))); + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } // add `status` to the URL query string if (getStatus() != null) { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java index 26c283c8db3..8b8b6d78ce7 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java @@ -136,6 +136,15 @@ public class ReadOnlyFirst { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -143,20 +152,30 @@ public class ReadOnlyFirst { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `bar` to the URL query string if (getBar() != null) { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `baz` to the URL query string if (getBaz() != null) { - joiner.add(String.format("%s[baz]=%s", prefix, URLEncoder.encode(String.valueOf(getBaz()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbaz%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBaz()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/SpecialModelName.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/SpecialModelName.java index b4fb3d3e65f..0e8d5e74acc 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/SpecialModelName.java @@ -107,6 +107,15 @@ public class SpecialModelName { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class SpecialModelName { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `$special[property.name]` to the URL query string if (get$SpecialPropertyName() != null) { - joiner.add(String.format("%s[$special[property.name]]=%s", prefix, URLEncoder.encode(String.valueOf(get$SpecialPropertyName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s$special[property.name]%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get$SpecialPropertyName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Tag.java index b37809ad184..e0af338ffba 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/Tag.java @@ -138,6 +138,15 @@ public class Tag { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Tag { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/User.java index 60942899633..52b1287573a 100644 --- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/User.java @@ -324,6 +324,15 @@ public class User { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -331,50 +340,60 @@ public class User { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `username` to the URL query string if (getUsername() != null) { - joiner.add(String.format("%s[username]=%s", prefix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%susername%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `firstName` to the URL query string if (getFirstName() != null) { - joiner.add(String.format("%s[firstName]=%s", prefix, URLEncoder.encode(String.valueOf(getFirstName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFirstName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `lastName` to the URL query string if (getLastName() != null) { - joiner.add(String.format("%s[lastName]=%s", prefix, URLEncoder.encode(String.valueOf(getLastName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%slastName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getLastName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `email` to the URL query string if (getEmail() != null) { - joiner.add(String.format("%s[email]=%s", prefix, URLEncoder.encode(String.valueOf(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `password` to the URL query string if (getPassword() != null) { - joiner.add(String.format("%s[password]=%s", prefix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spassword%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `phone` to the URL query string if (getPhone() != null) { - joiner.add(String.format("%s[phone]=%s", prefix, URLEncoder.encode(String.valueOf(getPhone()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphone%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPhone()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `userStatus` to the URL query string if (getUserStatus() != null) { - joiner.add(String.format("%s[userStatus]=%s", prefix, URLEncoder.encode(String.valueOf(getUserStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUserStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java index 2a574c157aa..b8269985344 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/PetApi.java @@ -292,16 +292,16 @@ public class PetApi { String localVarPath = "/pet/findByStatus"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "status"; localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -382,16 +382,16 @@ public class PetApi { String localVarPath = "/pet/findByTags"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "tags"; localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java index 86805d3d347..923943fb0f0 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/api/UserApi.java @@ -527,18 +527,18 @@ public class UserApi { String localVarPath = "/user/login"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "username"; localVarQueryParams.addAll(ApiClient.parameterToPairs("username", username)); localVarQueryParameterBaseName = "password"; localVarQueryParams.addAll(ApiClient.parameterToPairs("password", password)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java index 6175f25d974..098d777d994 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Category.java @@ -138,6 +138,15 @@ public class Category { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Category { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java index d73aea6ec34..1ac8d3f977e 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -169,6 +169,15 @@ public class ModelApiResponse { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -176,25 +185,35 @@ public class ModelApiResponse { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `code` to the URL query string if (getCode() != null) { - joiner.add(String.format("%s[code]=%s", prefix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scode%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `type` to the URL query string if (getType() != null) { - joiner.add(String.format("%s[type]=%s", prefix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `message` to the URL query string if (getMessage() != null) { - joiner.add(String.format("%s[message]=%s", prefix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java index ccae85f71c2..c64c67c42ab 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Order.java @@ -300,6 +300,15 @@ public class Order { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -307,40 +316,50 @@ public class Order { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `petId` to the URL query string if (getPetId() != null) { - joiner.add(String.format("%s[petId]=%s", prefix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spetId%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `quantity` to the URL query string if (getQuantity() != null) { - joiner.add(String.format("%s[quantity]=%s", prefix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%squantity%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `shipDate` to the URL query string if (getShipDate() != null) { - joiner.add(String.format("%s[shipDate]=%s", prefix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `status` to the URL query string if (getStatus() != null) { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `complete` to the URL query string if (getComplete() != null) { - joiner.add(String.format("%s[complete]=%s", prefix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java index 60fdec3bab0..77f6a63af29 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Pet.java @@ -318,6 +318,15 @@ public class Pet { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -325,31 +334,43 @@ public class Pet { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `category` to the URL query string if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "[category]")); + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `photoUrls` to the URL query string if (getPhotoUrls() != null) { for (int i = 0; i < getPhotoUrls().size(); i++) { - joiner.add(String.format("%s[photoUrls][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getPhotoUrls().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } @@ -357,14 +378,15 @@ public class Pet { if (getTags() != null) { for (int i = 0; i < getTags().size(); i++) { if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%s[tags][%d]", prefix, i))); + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } // add `status` to the URL query string if (getStatus() != null) { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java index f0417750de6..d59987169b9 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/Tag.java @@ -138,6 +138,15 @@ public class Tag { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Tag { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/User.java index a5f43504f82..61e347a889d 100644 --- a/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/native-jakarta/src/main/java/org/openapitools/client/model/User.java @@ -324,6 +324,15 @@ public class User { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -331,50 +340,60 @@ public class User { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `username` to the URL query string if (getUsername() != null) { - joiner.add(String.format("%s[username]=%s", prefix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%susername%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `firstName` to the URL query string if (getFirstName() != null) { - joiner.add(String.format("%s[firstName]=%s", prefix, URLEncoder.encode(String.valueOf(getFirstName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFirstName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `lastName` to the URL query string if (getLastName() != null) { - joiner.add(String.format("%s[lastName]=%s", prefix, URLEncoder.encode(String.valueOf(getLastName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%slastName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getLastName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `email` to the URL query string if (getEmail() != null) { - joiner.add(String.format("%s[email]=%s", prefix, URLEncoder.encode(String.valueOf(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `password` to the URL query string if (getPassword() != null) { - joiner.add(String.format("%s[password]=%s", prefix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spassword%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `phone` to the URL query string if (getPhone() != null) { - joiner.add(String.format("%s[phone]=%s", prefix, URLEncoder.encode(String.valueOf(getPhone()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphone%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPhone()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `userStatus` to the URL query string if (getUserStatus() != null) { - joiner.add(String.format("%s[userStatus]=%s", prefix, URLEncoder.encode(String.valueOf(getUserStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUserStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java index 7326d1bf059..72442b363fd 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/FakeApi.java @@ -216,16 +216,16 @@ public class FakeApi { String localVarPath = "/fake/http-signature-test"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query_1"; localVarQueryParams.addAll(ApiClient.parameterToPairs("query_1", query1)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -844,16 +844,16 @@ public class FakeApi { String localVarPath = "/fake/body-with-query-params"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "query"; localVarQueryParams.addAll(ApiClient.parameterToPairs("query", query)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -1140,7 +1140,7 @@ public class FakeApi { String localVarPath = "/fake"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "enum_query_string_array"; localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "enum_query_string_array", enumQueryStringArray)); @@ -1153,11 +1153,11 @@ public class FakeApi { localVarQueryParameterBaseName = "enum_query_model_array"; localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "enum_query_model_array", enumQueryModelArray)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -1294,7 +1294,7 @@ public class FakeApi { String localVarPath = "/fake"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "required_string_group"; localVarQueryParams.addAll(ApiClient.parameterToPairs("required_string_group", requiredStringGroup)); @@ -1305,11 +1305,11 @@ public class FakeApi { localVarQueryParameterBaseName = "int64_group"; localVarQueryParams.addAll(ApiClient.parameterToPairs("int64_group", int64Group)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -1664,7 +1664,7 @@ public class FakeApi { String localVarPath = "/fake/test-query-parameters"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "pipe"; localVarQueryParams.addAll(ApiClient.parameterToPairs("pipes", "pipe", pipe)); @@ -1681,11 +1681,11 @@ public class FakeApi { localVarQueryParameterBaseName = "allowEmpty"; localVarQueryParams.addAll(ApiClient.parameterToPairs("allowEmpty", allowEmpty)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java index bf60bc39294..bf3273344a5 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/PetApi.java @@ -296,16 +296,16 @@ public class PetApi { String localVarPath = "/pet/findByStatus"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "status"; localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "status", status)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { @@ -386,16 +386,16 @@ public class PetApi { String localVarPath = "/pet/findByTags"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "tags"; localVarQueryParams.addAll(ApiClient.parameterToPairs("csv", "tags", tags)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java index 1e4981fd60f..3e1e669cfc8 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/api/UserApi.java @@ -527,18 +527,18 @@ public class UserApi { String localVarPath = "/user/login"; List localVarQueryParams = new ArrayList<>(); - StringJoiner localVarQueryDeepObjectStringJoiner = new StringJoiner("&"); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); String localVarQueryParameterBaseName; localVarQueryParameterBaseName = "username"; localVarQueryParams.addAll(ApiClient.parameterToPairs("username", username)); localVarQueryParameterBaseName = "password"; localVarQueryParams.addAll(ApiClient.parameterToPairs("password", password)); - if (!localVarQueryParams.isEmpty() || localVarQueryDeepObjectStringJoiner.length() != 0) { + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { StringJoiner queryJoiner = new StringJoiner("&"); localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); - if (localVarQueryDeepObjectStringJoiner.length() != 0) { - queryJoiner.add(localVarQueryDeepObjectStringJoiner.toString()); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); } localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); } else { diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java index d2cedf566a1..b108c42adcb 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java @@ -156,6 +156,15 @@ public class AdditionalPropertiesClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -163,8 +172,18 @@ public class AdditionalPropertiesClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -172,14 +191,18 @@ public class AdditionalPropertiesClass { // add `map_property` to the URL query string if (getMapProperty() != null) { for (String _key : getMapProperty().keySet()) { - joiner.add(String.format("%s[map_property][%s]=%s", prefix, getMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_property%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `map_of_map_property` to the URL query string if (getMapOfMapProperty() != null) { for (String _key : getMapOfMapProperty().keySet()) { - joiner.add(String.format("%s[map_of_map_property][%s]=%s", prefix, getMapOfMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapOfMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_of_map_property%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapOfMapProperty().get(_key), URLEncoder.encode(String.valueOf(getMapOfMapProperty().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java index d6327307bc8..106abac0919 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/AllOfWithSingleRef.java @@ -139,6 +139,15 @@ public class AllOfWithSingleRef { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -146,20 +155,30 @@ public class AllOfWithSingleRef { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `username` to the URL query string if (getUsername() != null) { - joiner.add(String.format("%s[username]=%s", prefix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%susername%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `SingleRefType` to the URL query string if (getSingleRefType() != null) { - joiner.add(getSingleRefType().toUrlQueryString(prefix + "[SingleRefType]")); + joiner.add(getSingleRefType().toUrlQueryString(prefix + "SingleRefType" + suffix)); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Animal.java index 41f93d333f3..cffa1c6286a 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Animal.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Animal.java @@ -154,6 +154,15 @@ public class Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -161,20 +170,30 @@ public class Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `className` to the URL query string if (getClassName() != null) { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java index 25e3a70ae89..43ab3107a49 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java @@ -118,6 +118,15 @@ public class ArrayOfArrayOfNumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -125,8 +134,18 @@ public class ArrayOfArrayOfNumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -135,7 +154,9 @@ public class ArrayOfArrayOfNumberOnly { if (getArrayArrayNumber() != null) { for (int i = 0; i < getArrayArrayNumber().size(); i++) { if (getArrayArrayNumber().get(i) != null) { - joiner.add(String.format("%s[ArrayArrayNumber][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java index f21d71947b4..efa4b6f5c3b 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java @@ -118,6 +118,15 @@ public class ArrayOfNumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -125,8 +134,18 @@ public class ArrayOfNumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -135,7 +154,9 @@ public class ArrayOfNumberOnly { if (getArrayNumber() != null) { for (int i = 0; i < getArrayNumber().size(); i++) { if (getArrayNumber().get(i) != null) { - joiner.add(String.format("%s[ArrayNumber][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayTest.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayTest.java index ef82d407e11..0823c886177 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayTest.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayTest.java @@ -196,6 +196,15 @@ public class ArrayTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -203,8 +212,18 @@ public class ArrayTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -212,14 +231,18 @@ public class ArrayTest { // add `array_of_string` to the URL query string if (getArrayOfString() != null) { for (int i = 0; i < getArrayOfString().size(); i++) { - joiner.add(String.format("%s[array_of_string][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayOfString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_of_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayOfString().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `array_array_of_integer` to the URL query string if (getArrayArrayOfInteger() != null) { for (int i = 0; i < getArrayArrayOfInteger().size(); i++) { - joiner.add(String.format("%s[array_array_of_integer][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayOfInteger().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_array_of_integer%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayOfInteger().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } @@ -227,7 +250,9 @@ public class ArrayTest { if (getArrayArrayOfModel() != null) { for (int i = 0; i < getArrayArrayOfModel().size(); i++) { if (getArrayArrayOfModel().get(i) != null) { - joiner.add(String.format("%s[array_array_of_model][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayArrayOfModel().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_array_of_model%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayArrayOfModel().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Capitalization.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Capitalization.java index 86d5b3ac1c5..66035b10d5d 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Capitalization.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Capitalization.java @@ -262,6 +262,15 @@ public class Capitalization { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -269,40 +278,50 @@ public class Capitalization { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `smallCamel` to the URL query string if (getSmallCamel() != null) { - joiner.add(String.format("%s[smallCamel]=%s", prefix, URLEncoder.encode(String.valueOf(getSmallCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssmallCamel%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSmallCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `CapitalCamel` to the URL query string if (getCapitalCamel() != null) { - joiner.add(String.format("%s[CapitalCamel]=%s", prefix, URLEncoder.encode(String.valueOf(getCapitalCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sCapitalCamel%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCapitalCamel()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `small_Snake` to the URL query string if (getSmallSnake() != null) { - joiner.add(String.format("%s[small_Snake]=%s", prefix, URLEncoder.encode(String.valueOf(getSmallSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssmall_Snake%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSmallSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `Capital_Snake` to the URL query string if (getCapitalSnake() != null) { - joiner.add(String.format("%s[Capital_Snake]=%s", prefix, URLEncoder.encode(String.valueOf(getCapitalSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sCapital_Snake%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCapitalSnake()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `SCA_ETH_Flow_Points` to the URL query string if (getScAETHFlowPoints() != null) { - joiner.add(String.format("%s[SCA_ETH_Flow_Points]=%s", prefix, URLEncoder.encode(String.valueOf(getScAETHFlowPoints()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sSCA_ETH_Flow_Points%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getScAETHFlowPoints()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `ATT_NAME` to the URL query string if (getATTNAME() != null) { - joiner.add(String.format("%s[ATT_NAME]=%s", prefix, URLEncoder.encode(String.valueOf(getATTNAME()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sATT_NAME%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getATTNAME()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Cat.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Cat.java index 9b38295c889..8b85a7bb108 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Cat.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Cat.java @@ -120,6 +120,15 @@ public class Cat extends Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -127,25 +136,35 @@ public class Cat extends Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `className` to the URL query string if (getClassName() != null) { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `declawed` to the URL query string if (getDeclawed() != null) { - joiner.add(String.format("%s[declawed]=%s", prefix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdeclawed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/CatAllOf.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/CatAllOf.java index d0e93852876..488de1e892e 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/CatAllOf.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/CatAllOf.java @@ -107,6 +107,15 @@ public class CatAllOf { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class CatAllOf { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `declawed` to the URL query string if (getDeclawed() != null) { - joiner.add(String.format("%s[declawed]=%s", prefix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdeclawed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDeclawed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Category.java index f1c2fe8cf3c..3a31ec85e86 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Category.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Category.java @@ -138,6 +138,15 @@ public class Category { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Category { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ClassModel.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ClassModel.java index fa22b8dbd50..b0f7a754c33 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ClassModel.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ClassModel.java @@ -107,6 +107,15 @@ public class ClassModel { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ClassModel { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `_class` to the URL query string if (getPropertyClass() != null) { - joiner.add(String.format("%s[_class]=%s", prefix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s_class%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Client.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Client.java index 2845ad7612b..a6b6b93f0c8 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Client.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Client.java @@ -107,6 +107,15 @@ public class Client { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class Client { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `client` to the URL query string if (getClient() != null) { - joiner.add(String.format("%s[client]=%s", prefix, URLEncoder.encode(String.valueOf(getClient()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclient%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClient()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DeprecatedObject.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DeprecatedObject.java index 938c3ad013f..54d427bcf97 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DeprecatedObject.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DeprecatedObject.java @@ -109,6 +109,15 @@ public class DeprecatedObject { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -116,15 +125,25 @@ public class DeprecatedObject { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Dog.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Dog.java index 67fe2c689ab..e46cae8e00e 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Dog.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Dog.java @@ -120,6 +120,15 @@ public class Dog extends Animal { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -127,25 +136,35 @@ public class Dog extends Animal { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `className` to the URL query string if (getClassName() != null) { - joiner.add(String.format("%s[className]=%s", prefix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclassName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getClassName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `color` to the URL query string if (getColor() != null) { - joiner.add(String.format("%s[color]=%s", prefix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scolor%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getColor()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `breed` to the URL query string if (getBreed() != null) { - joiner.add(String.format("%s[breed]=%s", prefix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbreed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DogAllOf.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DogAllOf.java index 51a30fdb2a1..82d93902a71 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DogAllOf.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/DogAllOf.java @@ -107,6 +107,15 @@ public class DogAllOf { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class DogAllOf { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `breed` to the URL query string if (getBreed() != null) { - joiner.add(String.format("%s[breed]=%s", prefix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbreed%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBreed()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumArrays.java index 6f79cb8ffb4..ce493352a36 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -218,6 +218,15 @@ public class EnumArrays { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -225,21 +234,33 @@ public class EnumArrays { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `just_symbol` to the URL query string if (getJustSymbol() != null) { - joiner.add(String.format("%s[just_symbol]=%s", prefix, URLEncoder.encode(String.valueOf(getJustSymbol()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sjust_symbol%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getJustSymbol()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `array_enum` to the URL query string if (getArrayEnum() != null) { for (int i = 0; i < getArrayEnum().size(); i++) { - joiner.add(String.format("%s[array_enum][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayEnum().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_enum%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayEnum().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java index c364f9ec024..a7145b32bcb 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/EnumTest.java @@ -495,6 +495,15 @@ public class EnumTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -502,50 +511,60 @@ public class EnumTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `enum_string` to the URL query string if (getEnumString() != null) { - joiner.add(String.format("%s[enum_string]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_string%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `enum_string_required` to the URL query string if (getEnumStringRequired() != null) { - joiner.add(String.format("%s[enum_string_required]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumStringRequired()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_string_required%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumStringRequired()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `enum_integer` to the URL query string if (getEnumInteger() != null) { - joiner.add(String.format("%s[enum_integer]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_integer%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `enum_number` to the URL query string if (getEnumNumber() != null) { - joiner.add(String.format("%s[enum_number]=%s", prefix, URLEncoder.encode(String.valueOf(getEnumNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%senum_number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEnumNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnum` to the URL query string if (getOuterEnum() != null) { - joiner.add(String.format("%s[outerEnum]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnum()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnum%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnum()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnumInteger` to the URL query string if (getOuterEnumInteger() != null) { - joiner.add(String.format("%s[outerEnumInteger]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumInteger%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnumDefaultValue` to the URL query string if (getOuterEnumDefaultValue() != null) { - joiner.add(String.format("%s[outerEnumDefaultValue]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumDefaultValue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `outerEnumIntegerDefaultValue` to the URL query string if (getOuterEnumIntegerDefaultValue() != null) { - joiner.add(String.format("%s[outerEnumIntegerDefaultValue]=%s", prefix, URLEncoder.encode(String.valueOf(getOuterEnumIntegerDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%souterEnumIntegerDefaultValue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getOuterEnumIntegerDefaultValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java index 80cf3a96d69..69f36a8b0fd 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java @@ -149,6 +149,15 @@ public class FileSchemaTestClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -156,22 +165,33 @@ public class FileSchemaTestClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `file` to the URL query string if (getFile() != null) { - joiner.add(getFile().toUrlQueryString(prefix + "[file]")); + joiner.add(getFile().toUrlQueryString(prefix + "file" + suffix)); } // add `files` to the URL query string if (getFiles() != null) { for (int i = 0; i < getFiles().size(); i++) { if (getFiles().get(i) != null) { - joiner.add(getFiles().get(i).toUrlQueryString(String.format("%s[files][%d]", prefix, i))); + joiner.add(getFiles().get(i).toUrlQueryString(String.format("%sfiles%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Foo.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Foo.java index ba27aba5738..1d4de25f317 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Foo.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Foo.java @@ -107,6 +107,15 @@ public class Foo { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class Foo { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `bar` to the URL query string if (getBar() != null) { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java index d9926e3ad37..e978aaf2ee2 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FooGetDefaultResponse.java @@ -108,6 +108,15 @@ public class FooGetDefaultResponse { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -115,15 +124,25 @@ public class FooGetDefaultResponse { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `string` to the URL query string if (getString() != null) { - joiner.add(getString().toUrlQueryString(prefix + "[string]")); + joiner.add(getString().toUrlQueryString(prefix + "string" + suffix)); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FormatTest.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FormatTest.java index e65ec569af3..478fbb634c5 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FormatTest.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/FormatTest.java @@ -587,6 +587,15 @@ public class FormatTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -594,90 +603,100 @@ public class FormatTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `integer` to the URL query string if (getInteger() != null) { - joiner.add(String.format("%s[integer]=%s", prefix, URLEncoder.encode(String.valueOf(getInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sinteger%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInteger()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `int32` to the URL query string if (getInt32() != null) { - joiner.add(String.format("%s[int32]=%s", prefix, URLEncoder.encode(String.valueOf(getInt32()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sint32%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInt32()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `int64` to the URL query string if (getInt64() != null) { - joiner.add(String.format("%s[int64]=%s", prefix, URLEncoder.encode(String.valueOf(getInt64()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sint64%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getInt64()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `number` to the URL query string if (getNumber() != null) { - joiner.add(String.format("%s[number]=%s", prefix, URLEncoder.encode(String.valueOf(getNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%snumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `float` to the URL query string if (getFloat() != null) { - joiner.add(String.format("%s[float]=%s", prefix, URLEncoder.encode(String.valueOf(getFloat()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfloat%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFloat()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `double` to the URL query string if (getDouble() != null) { - joiner.add(String.format("%s[double]=%s", prefix, URLEncoder.encode(String.valueOf(getDouble()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdouble%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDouble()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `decimal` to the URL query string if (getDecimal() != null) { - joiner.add(String.format("%s[decimal]=%s", prefix, URLEncoder.encode(String.valueOf(getDecimal()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdecimal%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDecimal()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `string` to the URL query string if (getString() != null) { - joiner.add(String.format("%s[string]=%s", prefix, URLEncoder.encode(String.valueOf(getString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstring%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `byte` to the URL query string if (getByte() != null) { - joiner.add(String.format("%s[byte]=%s", prefix, URLEncoder.encode(String.valueOf(getByte()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbyte%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getByte()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `binary` to the URL query string if (getBinary() != null) { - joiner.add(String.format("%s[binary]=%s", prefix, URLEncoder.encode(String.valueOf(getBinary()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbinary%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBinary()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `date` to the URL query string if (getDate() != null) { - joiner.add(String.format("%s[date]=%s", prefix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `dateTime` to the URL query string if (getDateTime() != null) { - joiner.add(String.format("%s[dateTime]=%s", prefix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdateTime%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `uuid` to the URL query string if (getUuid() != null) { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `password` to the URL query string if (getPassword() != null) { - joiner.add(String.format("%s[password]=%s", prefix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spassword%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `pattern_with_digits` to the URL query string if (getPatternWithDigits() != null) { - joiner.add(String.format("%s[pattern_with_digits]=%s", prefix, URLEncoder.encode(String.valueOf(getPatternWithDigits()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spattern_with_digits%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPatternWithDigits()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `pattern_with_digits_and_delimiter` to the URL query string if (getPatternWithDigitsAndDelimiter() != null) { - joiner.add(String.format("%s[pattern_with_digits_and_delimiter]=%s", prefix, URLEncoder.encode(String.valueOf(getPatternWithDigitsAndDelimiter()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spattern_with_digits_and_delimiter%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPatternWithDigitsAndDelimiter()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java index 9081d5e8031..f6c4d6a7eb5 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java @@ -128,6 +128,15 @@ public class HasOnlyReadOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -135,20 +144,30 @@ public class HasOnlyReadOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `bar` to the URL query string if (getBar() != null) { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `foo` to the URL query string if (getFoo() != null) { - joiner.add(String.format("%s[foo]=%s", prefix, URLEncoder.encode(String.valueOf(getFoo()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfoo%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFoo()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HealthCheckResult.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HealthCheckResult.java index 4b8c287d70b..51e41ec085c 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HealthCheckResult.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/HealthCheckResult.java @@ -130,6 +130,15 @@ public class HealthCheckResult { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -137,15 +146,25 @@ public class HealthCheckResult { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `NullableMessage` to the URL query string if (getNullableMessage() != null) { - joiner.add(String.format("%s[NullableMessage]=%s", prefix, URLEncoder.encode(String.valueOf(getNullableMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sNullableMessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNullableMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MapTest.java index c04f87b0aef..f917d0265d0 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MapTest.java @@ -269,6 +269,15 @@ public class MapTest { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -276,8 +285,18 @@ public class MapTest { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); @@ -285,28 +304,36 @@ public class MapTest { // add `map_map_of_string` to the URL query string if (getMapMapOfString() != null) { for (String _key : getMapMapOfString().keySet()) { - joiner.add(String.format("%s[map_map_of_string][%s]=%s", prefix, getMapMapOfString().get(_key), URLEncoder.encode(String.valueOf(getMapMapOfString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_map_of_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapMapOfString().get(_key), URLEncoder.encode(String.valueOf(getMapMapOfString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `map_of_enum_string` to the URL query string if (getMapOfEnumString() != null) { for (String _key : getMapOfEnumString().keySet()) { - joiner.add(String.format("%s[map_of_enum_string][%s]=%s", prefix, getMapOfEnumString().get(_key), URLEncoder.encode(String.valueOf(getMapOfEnumString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smap_of_enum_string%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getMapOfEnumString().get(_key), URLEncoder.encode(String.valueOf(getMapOfEnumString().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `direct_map` to the URL query string if (getDirectMap() != null) { for (String _key : getDirectMap().keySet()) { - joiner.add(String.format("%s[direct_map][%s]=%s", prefix, getDirectMap().get(_key), URLEncoder.encode(String.valueOf(getDirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdirect_map%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getDirectMap().get(_key), URLEncoder.encode(String.valueOf(getDirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `indirect_map` to the URL query string if (getIndirectMap() != null) { for (String _key : getIndirectMap().keySet()) { - joiner.add(String.format("%s[indirect_map][%s]=%s", prefix, getIndirectMap().get(_key), URLEncoder.encode(String.valueOf(getIndirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sindirect_map%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getIndirectMap().get(_key), URLEncoder.encode(String.valueOf(getIndirectMap().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index c5b248d25cd..fe0b0e67c5f 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -182,6 +182,15 @@ public class MixedPropertiesAndAdditionalPropertiesClass { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -189,27 +198,38 @@ public class MixedPropertiesAndAdditionalPropertiesClass { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `uuid` to the URL query string if (getUuid() != null) { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `dateTime` to the URL query string if (getDateTime() != null) { - joiner.add(String.format("%s[dateTime]=%s", prefix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdateTime%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateTime()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `map` to the URL query string if (getMap() != null) { for (String _key : getMap().keySet()) { if (getMap().get(_key) != null) { - joiner.add(getMap().get(_key).toUrlQueryString(String.format("%s[map][%s]", prefix, _key))); + joiner.add(getMap().get(_key).toUrlQueryString(String.format("%smap%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix)))); } } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Model200Response.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Model200Response.java index 5fe66d61034..15c576c91da 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Model200Response.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Model200Response.java @@ -138,6 +138,15 @@ public class Model200Response { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Model200Response { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `class` to the URL query string if (getPropertyClass() != null) { - joiner.add(String.format("%s[class]=%s", prefix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sclass%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPropertyClass()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelApiResponse.java index 0fda9e67141..6f74d3ca962 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelApiResponse.java @@ -169,6 +169,15 @@ public class ModelApiResponse { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -176,25 +185,35 @@ public class ModelApiResponse { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `code` to the URL query string if (getCode() != null) { - joiner.add(String.format("%s[code]=%s", prefix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scode%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getCode()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `type` to the URL query string if (getType() != null) { - joiner.add(String.format("%s[type]=%s", prefix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%stype%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getType()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `message` to the URL query string if (getMessage() != null) { - joiner.add(String.format("%s[message]=%s", prefix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smessage%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMessage()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelFile.java index 149d2288e00..61ada7082fd 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelFile.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelFile.java @@ -107,6 +107,15 @@ public class ModelFile { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ModelFile { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `sourceURI` to the URL query string if (getSourceURI() != null) { - joiner.add(String.format("%s[sourceURI]=%s", prefix, URLEncoder.encode(String.valueOf(getSourceURI()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssourceURI%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSourceURI()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelList.java index 379d7c63c61..7e3e24c2d68 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelList.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelList.java @@ -107,6 +107,15 @@ public class ModelList { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ModelList { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `123-list` to the URL query string if (get123list() != null) { - joiner.add(String.format("%s[123-list]=%s", prefix, URLEncoder.encode(String.valueOf(get123list()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s123-list%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get123list()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelReturn.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelReturn.java index b3ad4492698..8c442eaeef1 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelReturn.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ModelReturn.java @@ -107,6 +107,15 @@ public class ModelReturn { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class ModelReturn { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `return` to the URL query string if (getReturn() != null) { - joiner.add(String.format("%s[return]=%s", prefix, URLEncoder.encode(String.valueOf(getReturn()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sreturn%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getReturn()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Name.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Name.java index 13e43af8c2e..ae795ee5c5d 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Name.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Name.java @@ -190,6 +190,15 @@ public class Name { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -197,30 +206,40 @@ public class Name { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `snake_case` to the URL query string if (getSnakeCase() != null) { - joiner.add(String.format("%s[snake_case]=%s", prefix, URLEncoder.encode(String.valueOf(getSnakeCase()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%ssnake_case%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getSnakeCase()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `property` to the URL query string if (getProperty() != null) { - joiner.add(String.format("%s[property]=%s", prefix, URLEncoder.encode(String.valueOf(getProperty()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sproperty%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getProperty()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `123Number` to the URL query string if (get123number() != null) { - joiner.add(String.format("%s[123Number]=%s", prefix, URLEncoder.encode(String.valueOf(get123number()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s123Number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get123number()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java index 9877503e43c..9b541d23092 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NullableClass.java @@ -665,6 +665,15 @@ public class NullableClass extends HashMap { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -672,81 +681,103 @@ public class NullableClass extends HashMap { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `integer_prop` to the URL query string if (getIntegerProp() != null) { - joiner.add(String.format("%s[integer_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getIntegerProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sinteger_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getIntegerProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `number_prop` to the URL query string if (getNumberProp() != null) { - joiner.add(String.format("%s[number_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getNumberProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%snumber_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getNumberProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `boolean_prop` to the URL query string if (getBooleanProp() != null) { - joiner.add(String.format("%s[boolean_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getBooleanProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sboolean_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBooleanProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `string_prop` to the URL query string if (getStringProp() != null) { - joiner.add(String.format("%s[string_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getStringProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstring_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStringProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `date_prop` to the URL query string if (getDateProp() != null) { - joiner.add(String.format("%s[date_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getDateProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdate_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDateProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `datetime_prop` to the URL query string if (getDatetimeProp() != null) { - joiner.add(String.format("%s[datetime_prop]=%s", prefix, URLEncoder.encode(String.valueOf(getDatetimeProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sdatetime_prop%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getDatetimeProp()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `array_nullable_prop` to the URL query string if (getArrayNullableProp() != null) { for (int i = 0; i < getArrayNullableProp().size(); i++) { - joiner.add(String.format("%s[array_nullable_prop][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `array_and_items_nullable_prop` to the URL query string if (getArrayAndItemsNullableProp() != null) { for (int i = 0; i < getArrayAndItemsNullableProp().size(); i++) { - joiner.add(String.format("%s[array_and_items_nullable_prop][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayAndItemsNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_and_items_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayAndItemsNullableProp().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `array_items_nullable` to the URL query string if (getArrayItemsNullable() != null) { for (int i = 0; i < getArrayItemsNullable().size(); i++) { - joiner.add(String.format("%s[array_items_nullable][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getArrayItemsNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sarray_items_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getArrayItemsNullable().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `object_nullable_prop` to the URL query string if (getObjectNullableProp() != null) { for (String _key : getObjectNullableProp().keySet()) { - joiner.add(String.format("%s[object_nullable_prop][%s]=%s", prefix, getObjectNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `object_and_items_nullable_prop` to the URL query string if (getObjectAndItemsNullableProp() != null) { for (String _key : getObjectAndItemsNullableProp().keySet()) { - joiner.add(String.format("%s[object_and_items_nullable_prop][%s]=%s", prefix, getObjectAndItemsNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectAndItemsNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_and_items_nullable_prop%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectAndItemsNullableProp().get(_key), URLEncoder.encode(String.valueOf(getObjectAndItemsNullableProp().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } // add `object_items_nullable` to the URL query string if (getObjectItemsNullable() != null) { for (String _key : getObjectItemsNullable().keySet()) { - joiner.add(String.format("%s[object_items_nullable][%s]=%s", prefix, getObjectItemsNullable().get(_key), URLEncoder.encode(String.valueOf(getObjectItemsNullable().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sobject_items_nullable%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, _key, containerSuffix), + getObjectItemsNullable().get(_key), URLEncoder.encode(String.valueOf(getObjectItemsNullable().get(_key)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NumberOnly.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NumberOnly.java index bcde8140bd8..55e6fb71822 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NumberOnly.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/NumberOnly.java @@ -108,6 +108,15 @@ public class NumberOnly { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -115,15 +124,25 @@ public class NumberOnly { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `JustNumber` to the URL query string if (getJustNumber() != null) { - joiner.add(String.format("%s[JustNumber]=%s", prefix, URLEncoder.encode(String.valueOf(getJustNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sJustNumber%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getJustNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java index 1c2be218ce3..461b96adb1e 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java @@ -218,6 +218,15 @@ public class ObjectWithDeprecatedFields { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -225,31 +234,43 @@ public class ObjectWithDeprecatedFields { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `uuid` to the URL query string if (getUuid() != null) { - joiner.add(String.format("%s[uuid]=%s", prefix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suuid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUuid()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `deprecatedRef` to the URL query string if (getDeprecatedRef() != null) { - joiner.add(getDeprecatedRef().toUrlQueryString(prefix + "[deprecatedRef]")); + joiner.add(getDeprecatedRef().toUrlQueryString(prefix + "deprecatedRef" + suffix)); } // add `bars` to the URL query string if (getBars() != null) { for (int i = 0; i < getBars().size(); i++) { - joiner.add(String.format("%s[bars][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(getBars().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbars%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getBars().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } } diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Order.java index 3f5c901bdbf..687b6b80ea3 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Order.java @@ -300,6 +300,15 @@ public class Order { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -307,40 +316,50 @@ public class Order { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `petId` to the URL query string if (getPetId() != null) { - joiner.add(String.format("%s[petId]=%s", prefix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spetId%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPetId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `quantity` to the URL query string if (getQuantity() != null) { - joiner.add(String.format("%s[quantity]=%s", prefix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%squantity%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getQuantity()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `shipDate` to the URL query string if (getShipDate() != null) { - joiner.add(String.format("%s[shipDate]=%s", prefix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sshipDate%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getShipDate()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `status` to the URL query string if (getStatus() != null) { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `complete` to the URL query string if (getComplete() != null) { - joiner.add(String.format("%s[complete]=%s", prefix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%scomplete%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getComplete()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterComposite.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterComposite.java index 13c55053ef6..d07b2ad8c78 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterComposite.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterComposite.java @@ -170,6 +170,15 @@ public class OuterComposite { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -177,25 +186,35 @@ public class OuterComposite { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `my_number` to the URL query string if (getMyNumber() != null) { - joiner.add(String.format("%s[my_number]=%s", prefix, URLEncoder.encode(String.valueOf(getMyNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_number%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyNumber()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `my_string` to the URL query string if (getMyString() != null) { - joiner.add(String.format("%s[my_string]=%s", prefix, URLEncoder.encode(String.valueOf(getMyString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_string%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyString()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `my_boolean` to the URL query string if (getMyBoolean() != null) { - joiner.add(String.format("%s[my_boolean]=%s", prefix, URLEncoder.encode(String.valueOf(getMyBoolean()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%smy_boolean%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getMyBoolean()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java index 1f5e24849c4..f19ffcca8af 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/OuterObjectWithEnumProperty.java @@ -108,6 +108,15 @@ public class OuterObjectWithEnumProperty { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -115,15 +124,25 @@ public class OuterObjectWithEnumProperty { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `value` to the URL query string if (getValue() != null) { - joiner.add(String.format("%s[value]=%s", prefix, URLEncoder.encode(String.valueOf(getValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%svalue%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getValue()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Pet.java index a022ceb3238..3aae87e766e 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Pet.java @@ -320,6 +320,15 @@ public class Pet { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -327,32 +336,44 @@ public class Pet { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `category` to the URL query string if (getCategory() != null) { - joiner.add(getCategory().toUrlQueryString(prefix + "[category]")); + joiner.add(getCategory().toUrlQueryString(prefix + "category" + suffix)); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `photoUrls` to the URL query string if (getPhotoUrls() != null) { int i = 0; for (String _item : getPhotoUrls()) { - joiner.add(String.format("%s[photoUrls][%d]=%s", prefix, i, URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphotoUrls%s%s=%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(_item), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } i++; } @@ -361,14 +382,15 @@ public class Pet { if (getTags() != null) { for (int i = 0; i < getTags().size(); i++) { if (getTags().get(i) != null) { - joiner.add(getTags().get(i).toUrlQueryString(String.format("%s[tags][%d]", prefix, i))); + joiner.add(getTags().get(i).toUrlQueryString(String.format("%stags%s%s", prefix, suffix, + "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); } } } // add `status` to the URL query string if (getStatus() != null) { - joiner.add(String.format("%s[status]=%s", prefix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sstatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java index 26c283c8db3..8b8b6d78ce7 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java @@ -136,6 +136,15 @@ public class ReadOnlyFirst { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -143,20 +152,30 @@ public class ReadOnlyFirst { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `bar` to the URL query string if (getBar() != null) { - joiner.add(String.format("%s[bar]=%s", prefix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbar%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBar()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `baz` to the URL query string if (getBaz() != null) { - joiner.add(String.format("%s[baz]=%s", prefix, URLEncoder.encode(String.valueOf(getBaz()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sbaz%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getBaz()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/SpecialModelName.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/SpecialModelName.java index b4fb3d3e65f..0e8d5e74acc 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/SpecialModelName.java @@ -107,6 +107,15 @@ public class SpecialModelName { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -114,15 +123,25 @@ public class SpecialModelName { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `$special[property.name]` to the URL query string if (get$SpecialPropertyName() != null) { - joiner.add(String.format("%s[$special[property.name]]=%s", prefix, URLEncoder.encode(String.valueOf(get$SpecialPropertyName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%s$special[property.name]%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(get$SpecialPropertyName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Tag.java index b37809ad184..e0af338ffba 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Tag.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/Tag.java @@ -138,6 +138,15 @@ public class Tag { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -145,20 +154,30 @@ public class Tag { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `name` to the URL query string if (getName() != null) { - joiner.add(String.format("%s[name]=%s", prefix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sname%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString(); diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/User.java index 60942899633..52b1287573a 100644 --- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/User.java +++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/User.java @@ -324,6 +324,15 @@ public class User { return o.toString().replace("\n", "\n "); } + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + /** * Convert the instance into URL query string. * @@ -331,50 +340,60 @@ public class User { * @return URL query string */ public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; } StringJoiner joiner = new StringJoiner("&"); // add `id` to the URL query string if (getId() != null) { - joiner.add(String.format("%s[id]=%s", prefix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sid%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getId()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `username` to the URL query string if (getUsername() != null) { - joiner.add(String.format("%s[username]=%s", prefix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%susername%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUsername()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `firstName` to the URL query string if (getFirstName() != null) { - joiner.add(String.format("%s[firstName]=%s", prefix, URLEncoder.encode(String.valueOf(getFirstName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sfirstName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getFirstName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `lastName` to the URL query string if (getLastName() != null) { - joiner.add(String.format("%s[lastName]=%s", prefix, URLEncoder.encode(String.valueOf(getLastName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%slastName%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getLastName()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `email` to the URL query string if (getEmail() != null) { - joiner.add(String.format("%s[email]=%s", prefix, URLEncoder.encode(String.valueOf(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%semail%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getEmail()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `password` to the URL query string if (getPassword() != null) { - joiner.add(String.format("%s[password]=%s", prefix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%spassword%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPassword()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `phone` to the URL query string if (getPhone() != null) { - joiner.add(String.format("%s[phone]=%s", prefix, URLEncoder.encode(String.valueOf(getPhone()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%sphone%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getPhone()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } // add `userStatus` to the URL query string if (getUserStatus() != null) { - joiner.add(String.format("%s[userStatus]=%s", prefix, URLEncoder.encode(String.valueOf(getUserStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); + joiner.add(String.format("%suserStatus%s=%s", prefix, suffix, URLEncoder.encode(String.valueOf(getUserStatus()), StandardCharsets.UTF_8).replaceAll("\\+", "%20"))); } return joiner.toString();