diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache index 032d398f6cd2..c80405ef2968 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache @@ -27,6 +27,7 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; {{/withXml}} import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; @@ -596,12 +597,46 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString(); } + /** + * Include queryParams in uriParams taking into account the paramName + * @param queryParam The query parameters + * @param uriParams The path parameters + * return templatized query string + */ + private String generateQueryUri(MultiValueMap queryParams, Map uriParams) { + StringBuilder queryBuilder = new StringBuilder(); + queryParams.forEach((name, values) -> { + if (CollectionUtils.isEmpty(values)) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + } else { + int valueItemCounter = 0; + for (Object value : values) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + if (value != null) { + String templatizedKey = name + valueItemCounter++; + uriParams.put(templatizedKey, value.toString()); + queryBuilder.append('=').append("{").append(templatizedKey).append("}"); + } + } + } + }); + return queryBuilder.toString(); + + } + /** * Invoke API by sending HTTP request with the given options. * * @param the return type to use * @param path The sub-path of the HTTP URL * @param method The request method + * @param pathParams The path parameters * @param queryParams The query parameters * @param body The request body object * @param headerParams The header parameters @@ -613,25 +648,22 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { * @param returnType The return type into which to deserialize the response * @return ResponseEntity<T> The response of the chosen type */ - public ResponseEntity invokeAPI(String path, HttpMethod method, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { + public ResponseEntity invokeAPI(String path, HttpMethod method, Map pathParams, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); - final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); - if (queryParams != null) { - //encode the query parameters in case they contain unsafe characters - for (List values : queryParams.values()) { - if (values != null) { - for (int i = 0; i < values.size(); i++) { - try { - values.set(i, URLEncoder.encode(values.get(i), "utf8")); - } catch (UnsupportedEncodingException e) { + Map uriParams = new HashMap(); + uriParams.putAll(pathParams); - } - } - } - } - builder.queryParams(queryParams); + String finalUri = path; + + if (queryParams != null && !queryParams.isEmpty()) { + //Include queryParams in uriParams taking into account the paramName + String queryUri = generateQueryUri(queryParams, uriParams); + //Append to finalUri the templatized query string like "?param1={param1Value}&....... + finalUri += "?" + queryUri; } + String expandedPath = this.expandPath(finalUri,uriParams); + final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(expandedPath); URI uri; try { @@ -815,3 +847,4 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { } } } + diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/api.mustache index acfec4bab58c..985d0f2b20f4 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/api.mustache @@ -116,7 +116,6 @@ public class {{classname}} { // create path and map variables final Map uriVariables = new HashMap();{{#pathParams}} uriVariables.put("{{baseName}}", {{#collectionFormat}}apiClient.collectionPathParameterToString(ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase()), {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}});{{/pathParams}}{{/hasPathParams}} - String path = apiClient.expandPath("{{{path}}}", {{#hasPathParams}}uriVariables{{/hasPathParams}}{{^hasPathParams}}Collections.emptyMap(){{/hasPathParams}}); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -150,8 +149,8 @@ public class {{classname}} { String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} }; {{#returnType}}ParameterizedTypeReference<{{{returnType}}}> returnType = new ParameterizedTypeReference<{{{returnType}}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference returnType = new ParameterizedTypeReference() {};{{/returnType}} - return apiClient.invokeAPI(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("{{{path}}}", HttpMethod.{{httpMethod}}, {{#hasPathParams}}uriVariables{{/hasPathParams}}{{^hasPathParams}}Collections.emptyMap(){{/hasPathParams}}, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } {{/operation}} } {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache index 677b8304f80e..28b91d3a1f87 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/webclient/ApiClient.mustache @@ -24,6 +24,7 @@ import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.http.codec.json.Jackson2JsonEncoder; +import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; @@ -610,16 +611,60 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} { return requestBuilder.retrieve(); } - private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map pathParams, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames) { + /** + * Include queryParams in uriParams taking into account the paramName + * @param queryParam The query parameters + * @param uriParams The path parameters + * return templatized query string + */ + private String generateQueryUri(MultiValueMap queryParams, Map uriParams) { + StringBuilder queryBuilder = new StringBuilder(); + queryParams.forEach((name, values) -> { + if (CollectionUtils.isEmpty(values)) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + } else { + int valueItemCounter = 0; + for (Object value : values) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + if (value != null) { + String templatizedKey = name + valueItemCounter++; + uriParams.put(templatizedKey, value.toString()); + queryBuilder.append('=').append("{").append(templatizedKey).append("}"); + } + } + } + }); + return queryBuilder.toString(); + } + + private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map pathParams, + MultiValueMap queryParams, Object body, HttpHeaders headerParams, + MultiValueMap cookieParams, MultiValueMap formParams, List accept, + MediaType contentType, String[] authNames) { updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); - if (queryParams != null) { - builder.queryParams(queryParams); + + String finalUri = builder.build(false).toUriString(); + Map uriParams = new HashMap(); + uriParams.putAll(pathParams); + + if (queryParams != null && !queryParams.isEmpty()) { + //Include queryParams in uriParams taking into account the paramName + String queryUri = generateQueryUri(queryParams, uriParams); + //Append to finalUri the templatized query string like "?param1={param1Value}&....... + finalUri += "?" + queryUri; } - final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(builder.build(false).toUriString(), pathParams); - if(accept != null) { + final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(finalUri, uriParams); + + if (accept != null) { requestBuilder.accept(accept.toArray(new MediaType[accept.size()])); } if(contentType != null) { diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ApiClient.java index ae98ba62fdcd..d9f4cc766120 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/ApiClient.java @@ -23,6 +23,7 @@ import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; @@ -553,12 +554,46 @@ public class ApiClient extends JavaTimeFormatter { return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString(); } + /** + * Include queryParams in uriParams taking into account the paramName + * @param queryParam The query parameters + * @param uriParams The path parameters + * return templatized query string + */ + private String generateQueryUri(MultiValueMap queryParams, Map uriParams) { + StringBuilder queryBuilder = new StringBuilder(); + queryParams.forEach((name, values) -> { + if (CollectionUtils.isEmpty(values)) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + } else { + int valueItemCounter = 0; + for (Object value : values) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + if (value != null) { + String templatizedKey = name + valueItemCounter++; + uriParams.put(templatizedKey, value.toString()); + queryBuilder.append('=').append("{").append(templatizedKey).append("}"); + } + } + } + }); + return queryBuilder.toString(); + + } + /** * Invoke API by sending HTTP request with the given options. * * @param the return type to use * @param path The sub-path of the HTTP URL * @param method The request method + * @param pathParams The path parameters * @param queryParams The query parameters * @param body The request body object * @param headerParams The header parameters @@ -570,25 +605,22 @@ public class ApiClient extends JavaTimeFormatter { * @param returnType The return type into which to deserialize the response * @return ResponseEntity<T> The response of the chosen type */ - public ResponseEntity invokeAPI(String path, HttpMethod method, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { + public ResponseEntity invokeAPI(String path, HttpMethod method, Map pathParams, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); - final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); - if (queryParams != null) { - //encode the query parameters in case they contain unsafe characters - for (List values : queryParams.values()) { - if (values != null) { - for (int i = 0; i < values.size(); i++) { - try { - values.set(i, URLEncoder.encode(values.get(i), "utf8")); - } catch (UnsupportedEncodingException e) { + Map uriParams = new HashMap(); + uriParams.putAll(pathParams); - } - } - } - } - builder.queryParams(queryParams); + String finalUri = path; + + if (queryParams != null && !queryParams.isEmpty()) { + //Include queryParams in uriParams taking into account the paramName + String queryUri = generateQueryUri(queryParams, uriParams); + //Append to finalUri the templatized query string like "?param1={param1Value}&....... + finalUri += "?" + queryUri; } + String expandedPath = this.expandPath(finalUri,uriParams); + final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(expandedPath); URI uri; try { @@ -766,3 +798,4 @@ public class ApiClient extends JavaTimeFormatter { } } } + diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index dee726fce33a..35a047040115 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -75,7 +75,6 @@ public class AnotherFakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling call123testSpecialTags"); } - String path = apiClient.expandPath("/another-fake/dummy", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -94,6 +93,6 @@ public class AnotherFakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PATCH, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/another-fake/dummy", HttpMethod.PATCH, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java index 045664b3bbbf..0d1f3836cc43 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeApi.java @@ -82,7 +82,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'xmlItem' when calling createXmlItem"); } - String path = apiClient.expandPath("/fake/create_xml_item", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -99,8 +98,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/create_xml_item", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of outer boolean types @@ -124,7 +123,6 @@ public class FakeApi { public ResponseEntity fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/boolean", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -141,8 +139,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/boolean", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of object with outer number type @@ -166,7 +164,6 @@ public class FakeApi { public ResponseEntity fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/composite", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -183,8 +180,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/composite", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of outer number types @@ -208,7 +205,6 @@ public class FakeApi { public ResponseEntity fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/number", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -225,8 +221,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/number", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of outer string types @@ -250,7 +246,6 @@ public class FakeApi { public ResponseEntity fakeOuterStringSerializeWithHttpInfo(String body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/string", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -267,8 +262,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/string", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * For this test, the body for this request much reference a schema named `File`. @@ -296,7 +291,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testBodyWithFileSchema"); } - String path = apiClient.expandPath("/fake/body-with-file-schema", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -313,8 +307,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/body-with-file-schema", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * @@ -349,7 +343,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testBodyWithQueryParams"); } - String path = apiClient.expandPath("/fake/body-with-query-params", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -368,8 +361,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/body-with-query-params", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * To test \"client\" model * To test \"client\" model @@ -398,7 +391,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testClientModel"); } - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -417,8 +409,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PATCH, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.PATCH, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -489,7 +481,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter '_byte' when calling testEndpointParameters"); } - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -535,8 +526,8 @@ public class FakeApi { String[] authNames = new String[] { "http_basic_test" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * To test enum parameters * To test enum parameters @@ -575,7 +566,6 @@ public class FakeApi { public ResponseEntity testEnumParametersWithHttpInfo(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws RestClientException { Object postBody = null; - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -607,8 +597,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Fake endpoint to test group parameters (optional) * Fake endpoint to test group parameters (optional) @@ -656,7 +646,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'requiredInt64Group' when calling testGroupParameters"); } - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -681,8 +670,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.DELETE, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * test inline additionalProperties * @@ -710,7 +699,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); } - String path = apiClient.expandPath("/fake/inline-additionalProperties", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -727,8 +715,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/inline-additionalProperties", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * test json serialization of form data * @@ -763,7 +751,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'param2' when calling testJsonFormData"); } - String path = apiClient.expandPath("/fake/jsonFormData", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -785,8 +772,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/jsonFormData", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * To test the collection format in query parameters @@ -842,7 +829,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'context' when calling testQueryParameterCollectionFormat"); } - String path = apiClient.expandPath("/fake/test-query-paramters", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -863,6 +849,6 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/test-query-paramters", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 26ad7b235468..0eb295cedaff 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -75,7 +75,6 @@ public class FakeClassnameTags123Api { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testClassname"); } - String path = apiClient.expandPath("/fake_classname_test", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -94,6 +93,6 @@ public class FakeClassnameTags123Api { String[] authNames = new String[] { "api_key_query" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PATCH, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake_classname_test", HttpMethod.PATCH, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java index 00a231be9c40..a720e65e2a68 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/PetApi.java @@ -79,7 +79,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling addPet"); } - String path = apiClient.expandPath("/pet", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -96,8 +95,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Deletes a pet * @@ -132,7 +131,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -150,8 +148,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}", HttpMethod.DELETE, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Finds Pets by status * Multiple status values can be provided with comma separated strings @@ -182,7 +180,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'status' when calling findPetsByStatus"); } - String path = apiClient.expandPath("/pet/findByStatus", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -201,8 +198,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference> returnType = new ParameterizedTypeReference>() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/findByStatus", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -237,7 +234,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'tags' when calling findPetsByTags"); } - String path = apiClient.expandPath("/pet/findByTags", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -256,8 +252,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference> returnType = new ParameterizedTypeReference>() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/findByTags", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Find pet by ID * Returns a single pet @@ -293,7 +289,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -310,8 +305,8 @@ public class PetApi { String[] authNames = new String[] { "api_key" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}", HttpMethod.GET, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Update an existing pet * @@ -345,7 +340,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling updatePet"); } - String path = apiClient.expandPath("/pet", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -362,8 +356,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Updates a pet in the store with form data * @@ -398,7 +392,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -420,8 +413,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}", HttpMethod.POST, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * uploads an image * @@ -457,7 +450,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}/uploadImage", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -481,8 +473,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}/uploadImage", HttpMethod.POST, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * uploads an image (required) * @@ -523,7 +515,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/fake/{petId}/uploadImageWithRequiredFile", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -547,6 +538,6 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/{petId}/uploadImageWithRequiredFile", HttpMethod.POST, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/StoreApi.java index 63aa265f38e4..8cc038b58b46 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/StoreApi.java @@ -79,7 +79,6 @@ public class StoreApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); - String path = apiClient.expandPath("/store/order/{order_id}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -94,8 +93,8 @@ public class StoreApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/order/{order_id}", HttpMethod.DELETE, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -117,7 +116,6 @@ public class StoreApi { public ResponseEntity> getInventoryWithHttpInfo() throws RestClientException { Object postBody = null; - String path = apiClient.expandPath("/store/inventory", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -134,8 +132,8 @@ public class StoreApi { String[] authNames = new String[] { "api_key" }; ParameterizedTypeReference> returnType = new ParameterizedTypeReference>() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/inventory", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -171,7 +169,6 @@ public class StoreApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); - String path = apiClient.expandPath("/store/order/{order_id}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -188,8 +185,8 @@ public class StoreApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/order/{order_id}", HttpMethod.GET, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Place an order for a pet * @@ -220,7 +217,6 @@ public class StoreApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling placeOrder"); } - String path = apiClient.expandPath("/store/order", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -237,6 +233,6 @@ public class StoreApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/order", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/UserApi.java index 46be8cbbd613..0dd22d8b9705 100644 --- a/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/resttemplate-withXml/src/main/java/org/openapitools/client/api/UserApi.java @@ -74,7 +74,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling createUser"); } - String path = apiClient.expandPath("/user", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -89,8 +88,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Creates list of users with given input array * @@ -118,7 +117,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); } - String path = apiClient.expandPath("/user/createWithArray", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -133,8 +131,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/createWithArray", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Creates list of users with given input array * @@ -162,7 +160,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling createUsersWithListInput"); } - String path = apiClient.expandPath("/user/createWithList", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -177,8 +174,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/createWithList", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Delete user * This can only be done by the logged in user. @@ -211,7 +208,6 @@ public class UserApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("username", username); - String path = apiClient.expandPath("/user/{username}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -226,8 +222,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/{username}", HttpMethod.DELETE, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Get user by user name * @@ -263,7 +259,6 @@ public class UserApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("username", username); - String path = apiClient.expandPath("/user/{username}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -280,8 +275,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/{username}", HttpMethod.GET, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Logs user into the system * @@ -319,7 +314,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'password' when calling loginUser"); } - String path = apiClient.expandPath("/user/login", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -339,8 +333,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/login", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Logs out current logged in user session * @@ -361,7 +355,6 @@ public class UserApi { public ResponseEntity logoutUserWithHttpInfo() throws RestClientException { Object postBody = null; - String path = apiClient.expandPath("/user/logout", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -376,8 +369,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/logout", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Updated user * This can only be done by the logged in user. @@ -417,7 +410,6 @@ public class UserApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("username", username); - String path = apiClient.expandPath("/user/{username}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -432,6 +424,6 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/{username}", HttpMethod.PUT, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java index ff33cd2248ff..8bf35d541270 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/ApiClient.java @@ -18,6 +18,7 @@ import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpResponse; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; @@ -548,12 +549,46 @@ public class ApiClient extends JavaTimeFormatter { return restTemplate.getUriTemplateHandler().expand(pathTemplate, variables).toString(); } + /** + * Include queryParams in uriParams taking into account the paramName + * @param queryParam The query parameters + * @param uriParams The path parameters + * return templatized query string + */ + private String generateQueryUri(MultiValueMap queryParams, Map uriParams) { + StringBuilder queryBuilder = new StringBuilder(); + queryParams.forEach((name, values) -> { + if (CollectionUtils.isEmpty(values)) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + } else { + int valueItemCounter = 0; + for (Object value : values) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + if (value != null) { + String templatizedKey = name + valueItemCounter++; + uriParams.put(templatizedKey, value.toString()); + queryBuilder.append('=').append("{").append(templatizedKey).append("}"); + } + } + } + }); + return queryBuilder.toString(); + + } + /** * Invoke API by sending HTTP request with the given options. * * @param the return type to use * @param path The sub-path of the HTTP URL * @param method The request method + * @param pathParams The path parameters * @param queryParams The query parameters * @param body The request body object * @param headerParams The header parameters @@ -565,25 +600,22 @@ public class ApiClient extends JavaTimeFormatter { * @param returnType The return type into which to deserialize the response * @return ResponseEntity<T> The response of the chosen type */ - public ResponseEntity invokeAPI(String path, HttpMethod method, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { + public ResponseEntity invokeAPI(String path, HttpMethod method, Map pathParams, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); - final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); - if (queryParams != null) { - //encode the query parameters in case they contain unsafe characters - for (List values : queryParams.values()) { - if (values != null) { - for (int i = 0; i < values.size(); i++) { - try { - values.set(i, URLEncoder.encode(values.get(i), "utf8")); - } catch (UnsupportedEncodingException e) { + Map uriParams = new HashMap(); + uriParams.putAll(pathParams); - } - } - } - } - builder.queryParams(queryParams); + String finalUri = path; + + if (queryParams != null && !queryParams.isEmpty()) { + //Include queryParams in uriParams taking into account the paramName + String queryUri = generateQueryUri(queryParams, uriParams); + //Append to finalUri the templatized query string like "?param1={param1Value}&....... + finalUri += "?" + queryUri; } + String expandedPath = this.expandPath(finalUri,uriParams); + final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(expandedPath); URI uri; try { @@ -753,3 +785,4 @@ public class ApiClient extends JavaTimeFormatter { } } } + diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index dee726fce33a..35a047040115 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -75,7 +75,6 @@ public class AnotherFakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling call123testSpecialTags"); } - String path = apiClient.expandPath("/another-fake/dummy", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -94,6 +93,6 @@ public class AnotherFakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PATCH, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/another-fake/dummy", HttpMethod.PATCH, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java index 045664b3bbbf..0d1f3836cc43 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeApi.java @@ -82,7 +82,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'xmlItem' when calling createXmlItem"); } - String path = apiClient.expandPath("/fake/create_xml_item", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -99,8 +98,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/create_xml_item", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of outer boolean types @@ -124,7 +123,6 @@ public class FakeApi { public ResponseEntity fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/boolean", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -141,8 +139,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/boolean", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of object with outer number type @@ -166,7 +164,6 @@ public class FakeApi { public ResponseEntity fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/composite", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -183,8 +180,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/composite", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of outer number types @@ -208,7 +205,6 @@ public class FakeApi { public ResponseEntity fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/number", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -225,8 +221,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/number", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * Test serialization of outer string types @@ -250,7 +246,6 @@ public class FakeApi { public ResponseEntity fakeOuterStringSerializeWithHttpInfo(String body) throws RestClientException { Object postBody = body; - String path = apiClient.expandPath("/fake/outer/string", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -267,8 +262,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/outer/string", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * For this test, the body for this request much reference a schema named `File`. @@ -296,7 +291,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testBodyWithFileSchema"); } - String path = apiClient.expandPath("/fake/body-with-file-schema", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -313,8 +307,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/body-with-file-schema", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * @@ -349,7 +343,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testBodyWithQueryParams"); } - String path = apiClient.expandPath("/fake/body-with-query-params", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -368,8 +361,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/body-with-query-params", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * To test \"client\" model * To test \"client\" model @@ -398,7 +391,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testClientModel"); } - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -417,8 +409,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PATCH, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.PATCH, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 @@ -489,7 +481,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter '_byte' when calling testEndpointParameters"); } - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -535,8 +526,8 @@ public class FakeApi { String[] authNames = new String[] { "http_basic_test" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * To test enum parameters * To test enum parameters @@ -575,7 +566,6 @@ public class FakeApi { public ResponseEntity testEnumParametersWithHttpInfo(List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List enumFormStringArray, String enumFormString) throws RestClientException { Object postBody = null; - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -607,8 +597,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Fake endpoint to test group parameters (optional) * Fake endpoint to test group parameters (optional) @@ -656,7 +646,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'requiredInt64Group' when calling testGroupParameters"); } - String path = apiClient.expandPath("/fake", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -681,8 +670,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake", HttpMethod.DELETE, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * test inline additionalProperties * @@ -710,7 +699,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'param' when calling testInlineAdditionalProperties"); } - String path = apiClient.expandPath("/fake/inline-additionalProperties", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -727,8 +715,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/inline-additionalProperties", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * test json serialization of form data * @@ -763,7 +751,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'param2' when calling testJsonFormData"); } - String path = apiClient.expandPath("/fake/jsonFormData", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -785,8 +772,8 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/jsonFormData", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * * To test the collection format in query parameters @@ -842,7 +829,6 @@ public class FakeApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'context' when calling testQueryParameterCollectionFormat"); } - String path = apiClient.expandPath("/fake/test-query-paramters", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -863,6 +849,6 @@ public class FakeApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/test-query-paramters", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 26ad7b235468..0eb295cedaff 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -75,7 +75,6 @@ public class FakeClassnameTags123Api { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling testClassname"); } - String path = apiClient.expandPath("/fake_classname_test", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -94,6 +93,6 @@ public class FakeClassnameTags123Api { String[] authNames = new String[] { "api_key_query" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PATCH, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake_classname_test", HttpMethod.PATCH, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java index 00a231be9c40..a720e65e2a68 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/PetApi.java @@ -79,7 +79,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling addPet"); } - String path = apiClient.expandPath("/pet", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -96,8 +95,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Deletes a pet * @@ -132,7 +131,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -150,8 +148,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}", HttpMethod.DELETE, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Finds Pets by status * Multiple status values can be provided with comma separated strings @@ -182,7 +180,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'status' when calling findPetsByStatus"); } - String path = apiClient.expandPath("/pet/findByStatus", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -201,8 +198,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference> returnType = new ParameterizedTypeReference>() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/findByStatus", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. @@ -237,7 +234,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'tags' when calling findPetsByTags"); } - String path = apiClient.expandPath("/pet/findByTags", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -256,8 +252,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference> returnType = new ParameterizedTypeReference>() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/findByTags", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Find pet by ID * Returns a single pet @@ -293,7 +289,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -310,8 +305,8 @@ public class PetApi { String[] authNames = new String[] { "api_key" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}", HttpMethod.GET, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Update an existing pet * @@ -345,7 +340,6 @@ public class PetApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling updatePet"); } - String path = apiClient.expandPath("/pet", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -362,8 +356,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet", HttpMethod.PUT, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Updates a pet in the store with form data * @@ -398,7 +392,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -420,8 +413,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}", HttpMethod.POST, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * uploads an image * @@ -457,7 +450,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/pet/{petId}/uploadImage", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -481,8 +473,8 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/pet/{petId}/uploadImage", HttpMethod.POST, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * uploads an image (required) * @@ -523,7 +515,6 @@ public class PetApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); - String path = apiClient.expandPath("/fake/{petId}/uploadImageWithRequiredFile", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -547,6 +538,6 @@ public class PetApi { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/fake/{petId}/uploadImageWithRequiredFile", HttpMethod.POST, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/StoreApi.java index 63aa265f38e4..8cc038b58b46 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/StoreApi.java @@ -79,7 +79,6 @@ public class StoreApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); - String path = apiClient.expandPath("/store/order/{order_id}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -94,8 +93,8 @@ public class StoreApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/order/{order_id}", HttpMethod.DELETE, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -117,7 +116,6 @@ public class StoreApi { public ResponseEntity> getInventoryWithHttpInfo() throws RestClientException { Object postBody = null; - String path = apiClient.expandPath("/store/inventory", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -134,8 +132,8 @@ public class StoreApi { String[] authNames = new String[] { "api_key" }; ParameterizedTypeReference> returnType = new ParameterizedTypeReference>() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/inventory", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -171,7 +169,6 @@ public class StoreApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); - String path = apiClient.expandPath("/store/order/{order_id}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -188,8 +185,8 @@ public class StoreApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/order/{order_id}", HttpMethod.GET, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Place an order for a pet * @@ -220,7 +217,6 @@ public class StoreApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling placeOrder"); } - String path = apiClient.expandPath("/store/order", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -237,6 +233,6 @@ public class StoreApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/store/order", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/UserApi.java index 46be8cbbd613..0dd22d8b9705 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/org/openapitools/client/api/UserApi.java @@ -74,7 +74,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling createUser"); } - String path = apiClient.expandPath("/user", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -89,8 +88,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Creates list of users with given input array * @@ -118,7 +117,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); } - String path = apiClient.expandPath("/user/createWithArray", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -133,8 +131,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/createWithArray", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Creates list of users with given input array * @@ -162,7 +160,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'body' when calling createUsersWithListInput"); } - String path = apiClient.expandPath("/user/createWithList", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -177,8 +174,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/createWithList", HttpMethod.POST, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Delete user * This can only be done by the logged in user. @@ -211,7 +208,6 @@ public class UserApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("username", username); - String path = apiClient.expandPath("/user/{username}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -226,8 +222,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/{username}", HttpMethod.DELETE, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Get user by user name * @@ -263,7 +259,6 @@ public class UserApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("username", username); - String path = apiClient.expandPath("/user/{username}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -280,8 +275,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/{username}", HttpMethod.GET, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Logs user into the system * @@ -319,7 +314,6 @@ public class UserApi { throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'password' when calling loginUser"); } - String path = apiClient.expandPath("/user/login", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -339,8 +333,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/login", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Logs out current logged in user session * @@ -361,7 +355,6 @@ public class UserApi { public ResponseEntity logoutUserWithHttpInfo() throws RestClientException { Object postBody = null; - String path = apiClient.expandPath("/user/logout", Collections.emptyMap()); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -376,8 +369,8 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/logout", HttpMethod.GET, Collections.emptyMap(), queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } /** * Updated user * This can only be done by the logged in user. @@ -417,7 +410,6 @@ public class UserApi { // create path and map variables final Map uriVariables = new HashMap(); uriVariables.put("username", username); - String path = apiClient.expandPath("/user/{username}", uriVariables); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); @@ -432,6 +424,6 @@ public class UserApi { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); - } + return apiClient.invokeAPI("/user/{username}", HttpMethod.PUT, uriVariables, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, authNames, returnType); + } } diff --git a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java index 6203192409ad..03a403f8a5d8 100644 --- a/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/webclient/src/main/java/org/openapitools/client/ApiClient.java @@ -22,6 +22,7 @@ import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.codec.json.Jackson2JsonDecoder; import org.springframework.http.codec.json.Jackson2JsonEncoder; +import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.util.StringUtils; @@ -597,16 +598,60 @@ public class ApiClient extends JavaTimeFormatter { return requestBuilder.retrieve(); } - private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map pathParams, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap cookieParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames) { + /** + * Include queryParams in uriParams taking into account the paramName + * @param queryParam The query parameters + * @param uriParams The path parameters + * return templatized query string + */ + private String generateQueryUri(MultiValueMap queryParams, Map uriParams) { + StringBuilder queryBuilder = new StringBuilder(); + queryParams.forEach((name, values) -> { + if (CollectionUtils.isEmpty(values)) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + } else { + int valueItemCounter = 0; + for (Object value : values) { + if (queryBuilder.length() != 0) { + queryBuilder.append('&'); + } + queryBuilder.append(name); + if (value != null) { + String templatizedKey = name + valueItemCounter++; + uriParams.put(templatizedKey, value.toString()); + queryBuilder.append('=').append("{").append(templatizedKey).append("}"); + } + } + } + }); + return queryBuilder.toString(); + } + + private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, Map pathParams, + MultiValueMap queryParams, Object body, HttpHeaders headerParams, + MultiValueMap cookieParams, MultiValueMap formParams, List accept, + MediaType contentType, String[] authNames) { updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); - if (queryParams != null) { - builder.queryParams(queryParams); + + String finalUri = builder.build(false).toUriString(); + Map uriParams = new HashMap(); + uriParams.putAll(pathParams); + + if (queryParams != null && !queryParams.isEmpty()) { + //Include queryParams in uriParams taking into account the paramName + String queryUri = generateQueryUri(queryParams, uriParams); + //Append to finalUri the templatized query string like "?param1={param1Value}&....... + finalUri += "?" + queryUri; } - final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(builder.build(false).toUriString(), pathParams); - if(accept != null) { + final WebClient.RequestBodySpec requestBuilder = webClient.method(method).uri(finalUri, uriParams); + + if (accept != null) { requestBuilder.accept(accept.toArray(new MediaType[accept.size()])); } if(contentType != null) {