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 323bae4e6d10..cdf398a0d580 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 @@ -86,11 +86,11 @@ public class ApiClient { return StringUtils.collectionToDelimitedString(collection, separator); } } - + private boolean debugging = false; - + private HttpHeaders defaultHeaders = new HttpHeaders(); - + private String basePath = "{{basePath}}"; private RestTemplate restTemplate; @@ -99,20 +99,20 @@ public class ApiClient { private HttpStatus statusCode; private MultiValueMap responseHeaders; - + private DateFormat dateFormat; public ApiClient() { this.restTemplate = buildRestTemplate(); init(); } - + @Autowired public ApiClient(RestTemplate restTemplate) { this.restTemplate = restTemplate; init(); } - + protected void init() { // Use RFC3339 format for date and datetime. // See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 @@ -132,7 +132,7 @@ public class ApiClient { // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } - + /** * Get the current base path * @return String the base path @@ -281,7 +281,7 @@ public class ApiClient { defaultHeaders.add(name, value); return this; } - + public void setDebugging(boolean debugging) { List currentInterceptors = this.restTemplate.getInterceptors(); if(debugging) { @@ -339,7 +339,7 @@ public class ApiClient { {{/threetenbp}} return this; } - + /** * Parse the given string into Date object. */ @@ -382,6 +382,28 @@ public class ApiClient { } } + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(CollectionFormat collectionFormat, Collection values) { + // create the value based on the collection format + if (CollectionFormat.MULTI.equals(collectionFormat)) { + // not valid for path params + return parameterToString(values); + } + + // collectionFormat is assumed to be "csv" by default + if(collectionFormat == null) { + collectionFormat = CollectionFormat.CSV; + } + + return collectionFormat.collectionToString(values); + } + /** * Converts a parameter to a {@link MultiValueMap} for use in REST requests * @param collectionFormat The format to convert to @@ -531,7 +553,7 @@ public class ApiClient { */ public T invokeAPI(String path, HttpMethod method, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { updateParamsForAuth(authNames, queryParams, headerParams); - + final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); if (queryParams != null) { //encode the query parameters in case they contain unsafe characters @@ -548,14 +570,14 @@ public class ApiClient { } builder.queryParams(queryParams); } - + URI uri; try { uri = new URI(builder.build().toUriString()); } catch(URISyntaxException ex) { throw new RestClientException("Could not build URL: " + builder.toUriString(), ex); } - + final BodyBuilder requestBuilder = RequestEntity.method(method, uri); if(accept != null) { requestBuilder.accept(accept.toArray(new MediaType[accept.size()])); @@ -563,14 +585,14 @@ public class ApiClient { if(contentType != null) { requestBuilder.contentType(contentType); } - + addHeadersToRequest(headerParams, requestBuilder); addHeadersToRequest(defaultHeaders, requestBuilder); - + RequestEntity requestEntity = requestBuilder.body(selectBody(body, formParams, contentType)); ResponseEntity responseEntity = restTemplate.exchange(requestEntity, returnType); - + statusCode = responseEntity.getStatusCode(); responseHeaders = responseEntity.getHeaders(); @@ -586,7 +608,7 @@ public class ApiClient { throw new RestClientException("API returned " + statusCode + " and it wasn't handled by the RestTemplate error handler"); } } - + /** * Add headers to the request that is being built * @param headers The headers to add @@ -649,7 +671,7 @@ public class ApiClient { auth.applyToParams(queryParams, headerParams); } } - + private class ApiClientHttpRequestInterceptor implements ClientHttpRequestInterceptor { private final Log log = LogFactory.getLog(ApiClientHttpRequestInterceptor.class); @@ -688,7 +710,7 @@ public class ApiClient { builder.setLength(builder.length() - 1); // Get rid of trailing comma return builder.toString(); } - + private String bodyToString(InputStream body) throws IOException { StringBuilder builder = new StringBuilder(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(body, StandardCharsets.UTF_8)); 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 beede4b55b18..e52b822b1063 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 @@ -71,20 +71,20 @@ public class {{classname}} { {{/required}}{{/allParams}}{{#hasPathParams}} // create path and map variables final Map uriVariables = new HashMap();{{#pathParams}} - uriVariables.put("{{baseName}}", {{{paramName}}});{{/pathParams}}{{/hasPathParams}} + uriVariables.put("{{baseName}}", {{#collectionFormat}}apiClient.collectionPathParameterToString(ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase()), {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}});{{/pathParams}}{{/hasPathParams}} String {{localVariablePrefix}}path = UriComponentsBuilder.fromPath("{{{path}}}"){{#hasPathParams}}.buildAndExpand(uriVariables){{/hasPathParams}}{{^hasPathParams}}.build(){{/hasPathParams}}.toUriString(); - + final MultiValueMap {{localVariablePrefix}}queryParams = new LinkedMultiValueMap(); final HttpHeaders {{localVariablePrefix}}headerParams = new HttpHeaders(); final MultiValueMap {{localVariablePrefix}}formParams = new LinkedMultiValueMap();{{#hasQueryParams}} - + {{#queryParams}}{{localVariablePrefix}}queryParams.putAll({{localVariablePrefix}}apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));{{#hasMore}} {{/hasMore}}{{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}} - + {{#headerParams}}if ({{paramName}} != null) {{localVariablePrefix}}headerParams.add("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));{{#hasMore}} {{/hasMore}}{{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}} - + {{#formParams}}if ({{paramName}} != null) {{localVariablePrefix}}formParams.add("{{baseName}}", {{#isFile}}new FileSystemResource({{paramName}}){{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}} {{/hasMore}}{{/formParams}}{{/hasFormParams}} 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 c1be2519f364..c06f80a1381a 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 @@ -78,11 +78,11 @@ private String collectionToString(Collection collection) return StringUtils.collectionToDelimitedString(collection, separator); } } - + private boolean debugging = false; - + private HttpHeaders defaultHeaders = new HttpHeaders(); - + private String basePath = "http://petstore.swagger.io:80/v2"; private RestTemplate restTemplate; @@ -91,20 +91,20 @@ private String collectionToString(Collection collection) private HttpStatus statusCode; private MultiValueMap responseHeaders; - + private DateFormat dateFormat; public ApiClient() { this.restTemplate = buildRestTemplate(); init(); } - + @Autowired public ApiClient(RestTemplate restTemplate) { this.restTemplate = restTemplate; init(); } - + protected void init() { // Use RFC3339 format for date and datetime. // See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 @@ -125,7 +125,7 @@ protected void init() { // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } - + /** * Get the current base path * @return String the base path @@ -272,7 +272,7 @@ public ApiClient addDefaultHeader(String name, String value) { defaultHeaders.add(name, value); return this; } - + public void setDebugging(boolean debugging) { List currentInterceptors = this.restTemplate.getInterceptors(); if(debugging) { @@ -328,7 +328,7 @@ public ApiClient setDateFormat(DateFormat dateFormat) { } return this; } - + /** * Parse the given string into Date object. */ @@ -371,6 +371,28 @@ public String parameterToString(Object param) { } } + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(CollectionFormat collectionFormat, Collection values) { + // create the value based on the collection format + if (CollectionFormat.MULTI.equals(collectionFormat)) { + // not valid for path params + return parameterToString(values); + } + + // collectionFormat is assumed to be "csv" by default + if(collectionFormat == null) { + collectionFormat = CollectionFormat.CSV; + } + + return collectionFormat.collectionToString(values); + } + /** * Converts a parameter to a {@link MultiValueMap} for use in REST requests * @param collectionFormat The format to convert to @@ -520,7 +542,7 @@ protected Object selectBody(Object obj, MultiValueMap formParams */ public T invokeAPI(String path, HttpMethod method, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { updateParamsForAuth(authNames, queryParams, headerParams); - + final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); if (queryParams != null) { //encode the query parameters in case they contain unsafe characters @@ -537,14 +559,14 @@ public T invokeAPI(String path, HttpMethod method, MultiValueMap T invokeAPI(String path, HttpMethod method, MultiValueMap requestEntity = requestBuilder.body(selectBody(body, formParams, contentType)); ResponseEntity responseEntity = restTemplate.exchange(requestEntity, returnType); - + statusCode = responseEntity.getStatusCode(); responseHeaders = responseEntity.getHeaders(); @@ -575,7 +597,7 @@ public T invokeAPI(String path, HttpMethod method, MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); 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 333d47ce5219..9d607296978f 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 @@ -70,7 +70,7 @@ public void createXmlItem(XmlItem xmlItem) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/fake/create_xml_item").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -99,7 +99,7 @@ public Boolean fakeOuterBooleanSerialize(Boolean body) throws RestClientExceptio Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/boolean").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -128,7 +128,7 @@ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Re Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/composite").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -157,7 +157,7 @@ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws RestClientExc Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/number").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -186,7 +186,7 @@ public String fakeOuterStringSerialize(String body) throws RestClientException { Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/string").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -219,7 +219,7 @@ public void testBodyWithFileSchema(FileSchemaTestClass body) throws RestClientEx } String path = UriComponentsBuilder.fromPath("/fake/body-with-file-schema").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -258,11 +258,11 @@ public void testBodyWithQueryParams(String query, User body) throws RestClientEx } String path = UriComponentsBuilder.fromPath("/fake/body-with-query-params").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(null, "query", query)); final String[] accepts = { }; @@ -294,7 +294,7 @@ public Client testClientModel(Client body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -358,11 +358,11 @@ public void testEndpointParameters(BigDecimal number, Double _double, String pat } String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (integer != null) formParams.add("integer", integer); if (int32 != null) @@ -423,21 +423,21 @@ public void testEnumParameters(List enumHeaderStringArray, String enumHe Object postBody = null; String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("csv".toUpperCase(Locale.ROOT)), "enum_query_string_array", enumQueryStringArray)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_string", enumQueryString)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_integer", enumQueryInteger)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_double", enumQueryDouble)); - + if (enumHeaderStringArray != null) headerParams.add("enum_header_string_array", apiClient.parameterToString(enumHeaderStringArray)); if (enumHeaderString != null) headerParams.add("enum_header_string", apiClient.parameterToString(enumHeaderString)); - + if (enumFormStringArray != null) formParams.add("enum_form_string_array", enumFormStringArray); if (enumFormString != null) @@ -486,16 +486,16 @@ public void testGroupParameters(Integer requiredStringGroup, Boolean requiredBoo } String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(null, "required_string_group", requiredStringGroup)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "required_int64_group", requiredInt64Group)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "string_group", stringGroup)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "int64_group", int64Group)); - + if (requiredBooleanGroup != null) headerParams.add("required_boolean_group", apiClient.parameterToString(requiredBooleanGroup)); if (booleanGroup != null) @@ -527,7 +527,7 @@ public void testInlineAdditionalProperties(Map param) throws Res } String path = UriComponentsBuilder.fromPath("/fake/inline-additionalProperties").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -566,11 +566,11 @@ public void testJsonFormData(String param, String param2) throws RestClientExcep } String path = UriComponentsBuilder.fromPath("/fake/jsonFormData").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (param != null) formParams.add("param", param); if (param2 != null) 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 6e143bcb13b5..c0e2aef1afe2 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 @@ -63,7 +63,7 @@ public Client testClassname(Client body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/fake_classname_test").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); 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 fc786ed3ba58..2845d3dc08ab 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 @@ -64,7 +64,7 @@ public void addPet(Pet body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/pet").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -101,11 +101,11 @@ public void deletePet(Long petId, String apiKey) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (apiKey != null) headerParams.add("api_key", apiClient.parameterToString(apiKey)); @@ -137,11 +137,11 @@ public List findPetsByStatus(List status) throws RestClientExceptio } String path = UriComponentsBuilder.fromPath("/pet/findByStatus").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("csv".toUpperCase(Locale.ROOT)), "status", status)); final String[] accepts = { @@ -174,11 +174,11 @@ public List findPetsByTags(List tags) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/pet/findByTags").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("csv".toUpperCase(Locale.ROOT)), "tags", tags)); final String[] accepts = { @@ -215,7 +215,7 @@ public Pet getPetById(Long petId) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -250,7 +250,7 @@ public void updatePet(Pet body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/pet").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -288,11 +288,11 @@ public void updatePetWithForm(Long petId, String name, String status) throws Res final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (name != null) formParams.add("name", name); if (status != null) @@ -332,11 +332,11 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File f final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}/uploadImage").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (additionalMetadata != null) formParams.add("additionalMetadata", additionalMetadata); if (file != null) @@ -383,11 +383,11 @@ public ModelApiResponse uploadFileWithRequiredFile(Long petId, File requiredFile final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/fake/{petId}/uploadImageWithRequiredFile").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (additionalMetadata != null) formParams.add("additionalMetadata", additionalMetadata); if (requiredFile != null) 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 ae3c0f770b23..0bf4604d28d6 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 @@ -66,7 +66,7 @@ public void deleteOrder(String orderId) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); String path = UriComponentsBuilder.fromPath("/store/order/{order_id}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -92,7 +92,7 @@ public Map getInventory() throws RestClientException { Object postBody = null; String path = UriComponentsBuilder.fromPath("/store/inventory").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -131,7 +131,7 @@ public Order getOrderById(Long orderId) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); String path = UriComponentsBuilder.fromPath("/store/order/{order_id}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -166,7 +166,7 @@ public Order placeOrder(Order body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/store/order").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); 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 024f32474562..586e2320a808 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 @@ -62,7 +62,7 @@ public void createUser(User body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/user").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -93,7 +93,7 @@ public void createUsersWithArrayInput(List body) throws RestClientExceptio } String path = UriComponentsBuilder.fromPath("/user/createWithArray").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -124,7 +124,7 @@ public void createUsersWithListInput(List body) throws RestClientException } String path = UriComponentsBuilder.fromPath("/user/createWithList").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -159,7 +159,7 @@ public void deleteUser(String username) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("username", username); String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -196,7 +196,7 @@ public User getUserByName(String username) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("username", username); String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -237,11 +237,11 @@ public String loginUser(String username, String password) throws RestClientExcep } String path = UriComponentsBuilder.fromPath("/user/login").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(null, "username", username)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "password", password)); @@ -267,7 +267,7 @@ public void logoutUser() throws RestClientException { Object postBody = null; String path = UriComponentsBuilder.fromPath("/user/logout").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -308,7 +308,7 @@ public void updateUser(String username, User body) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("username", username); String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); 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 b2c42fc58a17..e0c50a4e8670 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 @@ -73,11 +73,11 @@ private String collectionToString(Collection collection) return StringUtils.collectionToDelimitedString(collection, separator); } } - + private boolean debugging = false; - + private HttpHeaders defaultHeaders = new HttpHeaders(); - + private String basePath = "http://petstore.swagger.io:80/v2"; private RestTemplate restTemplate; @@ -86,20 +86,20 @@ private String collectionToString(Collection collection) private HttpStatus statusCode; private MultiValueMap responseHeaders; - + private DateFormat dateFormat; public ApiClient() { this.restTemplate = buildRestTemplate(); init(); } - + @Autowired public ApiClient(RestTemplate restTemplate) { this.restTemplate = restTemplate; init(); } - + protected void init() { // Use RFC3339 format for date and datetime. // See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 @@ -120,7 +120,7 @@ protected void init() { // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } - + /** * Get the current base path * @return String the base path @@ -267,7 +267,7 @@ public ApiClient addDefaultHeader(String name, String value) { defaultHeaders.add(name, value); return this; } - + public void setDebugging(boolean debugging) { List currentInterceptors = this.restTemplate.getInterceptors(); if(debugging) { @@ -323,7 +323,7 @@ public ApiClient setDateFormat(DateFormat dateFormat) { } return this; } - + /** * Parse the given string into Date object. */ @@ -366,6 +366,28 @@ public String parameterToString(Object param) { } } + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(CollectionFormat collectionFormat, Collection values) { + // create the value based on the collection format + if (CollectionFormat.MULTI.equals(collectionFormat)) { + // not valid for path params + return parameterToString(values); + } + + // collectionFormat is assumed to be "csv" by default + if(collectionFormat == null) { + collectionFormat = CollectionFormat.CSV; + } + + return collectionFormat.collectionToString(values); + } + /** * Converts a parameter to a {@link MultiValueMap} for use in REST requests * @param collectionFormat The format to convert to @@ -515,7 +537,7 @@ protected Object selectBody(Object obj, MultiValueMap formParams */ public T invokeAPI(String path, HttpMethod method, MultiValueMap queryParams, Object body, HttpHeaders headerParams, MultiValueMap formParams, List accept, MediaType contentType, String[] authNames, ParameterizedTypeReference returnType) throws RestClientException { updateParamsForAuth(authNames, queryParams, headerParams); - + final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); if (queryParams != null) { //encode the query parameters in case they contain unsafe characters @@ -532,14 +554,14 @@ public T invokeAPI(String path, HttpMethod method, MultiValueMap T invokeAPI(String path, HttpMethod method, MultiValueMap requestEntity = requestBuilder.body(selectBody(body, formParams, contentType)); ResponseEntity responseEntity = restTemplate.exchange(requestEntity, returnType); - + statusCode = responseEntity.getStatusCode(); responseHeaders = responseEntity.getHeaders(); @@ -570,7 +592,7 @@ public T invokeAPI(String path, HttpMethod method, MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); 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 333d47ce5219..9d607296978f 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 @@ -70,7 +70,7 @@ public void createXmlItem(XmlItem xmlItem) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/fake/create_xml_item").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -99,7 +99,7 @@ public Boolean fakeOuterBooleanSerialize(Boolean body) throws RestClientExceptio Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/boolean").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -128,7 +128,7 @@ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Re Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/composite").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -157,7 +157,7 @@ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws RestClientExc Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/number").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -186,7 +186,7 @@ public String fakeOuterStringSerialize(String body) throws RestClientException { Object postBody = body; String path = UriComponentsBuilder.fromPath("/fake/outer/string").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -219,7 +219,7 @@ public void testBodyWithFileSchema(FileSchemaTestClass body) throws RestClientEx } String path = UriComponentsBuilder.fromPath("/fake/body-with-file-schema").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -258,11 +258,11 @@ public void testBodyWithQueryParams(String query, User body) throws RestClientEx } String path = UriComponentsBuilder.fromPath("/fake/body-with-query-params").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(null, "query", query)); final String[] accepts = { }; @@ -294,7 +294,7 @@ public Client testClientModel(Client body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -358,11 +358,11 @@ public void testEndpointParameters(BigDecimal number, Double _double, String pat } String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (integer != null) formParams.add("integer", integer); if (int32 != null) @@ -423,21 +423,21 @@ public void testEnumParameters(List enumHeaderStringArray, String enumHe Object postBody = null; String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("csv".toUpperCase(Locale.ROOT)), "enum_query_string_array", enumQueryStringArray)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_string", enumQueryString)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_integer", enumQueryInteger)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_double", enumQueryDouble)); - + if (enumHeaderStringArray != null) headerParams.add("enum_header_string_array", apiClient.parameterToString(enumHeaderStringArray)); if (enumHeaderString != null) headerParams.add("enum_header_string", apiClient.parameterToString(enumHeaderString)); - + if (enumFormStringArray != null) formParams.add("enum_form_string_array", enumFormStringArray); if (enumFormString != null) @@ -486,16 +486,16 @@ public void testGroupParameters(Integer requiredStringGroup, Boolean requiredBoo } String path = UriComponentsBuilder.fromPath("/fake").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(null, "required_string_group", requiredStringGroup)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "required_int64_group", requiredInt64Group)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "string_group", stringGroup)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "int64_group", int64Group)); - + if (requiredBooleanGroup != null) headerParams.add("required_boolean_group", apiClient.parameterToString(requiredBooleanGroup)); if (booleanGroup != null) @@ -527,7 +527,7 @@ public void testInlineAdditionalProperties(Map param) throws Res } String path = UriComponentsBuilder.fromPath("/fake/inline-additionalProperties").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -566,11 +566,11 @@ public void testJsonFormData(String param, String param2) throws RestClientExcep } String path = UriComponentsBuilder.fromPath("/fake/jsonFormData").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (param != null) formParams.add("param", param); if (param2 != null) 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 6e143bcb13b5..c0e2aef1afe2 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 @@ -63,7 +63,7 @@ public Client testClassname(Client body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/fake_classname_test").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); 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 fc786ed3ba58..2845d3dc08ab 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 @@ -64,7 +64,7 @@ public void addPet(Pet body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/pet").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -101,11 +101,11 @@ public void deletePet(Long petId, String apiKey) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (apiKey != null) headerParams.add("api_key", apiClient.parameterToString(apiKey)); @@ -137,11 +137,11 @@ public List findPetsByStatus(List status) throws RestClientExceptio } String path = UriComponentsBuilder.fromPath("/pet/findByStatus").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("csv".toUpperCase(Locale.ROOT)), "status", status)); final String[] accepts = { @@ -174,11 +174,11 @@ public List findPetsByTags(List tags) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/pet/findByTags").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(ApiClient.CollectionFormat.valueOf("csv".toUpperCase(Locale.ROOT)), "tags", tags)); final String[] accepts = { @@ -215,7 +215,7 @@ public Pet getPetById(Long petId) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -250,7 +250,7 @@ public void updatePet(Pet body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/pet").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -288,11 +288,11 @@ public void updatePetWithForm(Long petId, String name, String status) throws Res final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (name != null) formParams.add("name", name); if (status != null) @@ -332,11 +332,11 @@ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File f final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/pet/{petId}/uploadImage").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (additionalMetadata != null) formParams.add("additionalMetadata", additionalMetadata); if (file != null) @@ -383,11 +383,11 @@ public ModelApiResponse uploadFileWithRequiredFile(Long petId, File requiredFile final Map uriVariables = new HashMap(); uriVariables.put("petId", petId); String path = UriComponentsBuilder.fromPath("/fake/{petId}/uploadImageWithRequiredFile").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + if (additionalMetadata != null) formParams.add("additionalMetadata", additionalMetadata); if (requiredFile != null) 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 ae3c0f770b23..0bf4604d28d6 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 @@ -66,7 +66,7 @@ public void deleteOrder(String orderId) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); String path = UriComponentsBuilder.fromPath("/store/order/{order_id}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -92,7 +92,7 @@ public Map getInventory() throws RestClientException { Object postBody = null; String path = UriComponentsBuilder.fromPath("/store/inventory").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -131,7 +131,7 @@ public Order getOrderById(Long orderId) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("order_id", orderId); String path = UriComponentsBuilder.fromPath("/store/order/{order_id}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -166,7 +166,7 @@ public Order placeOrder(Order body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/store/order").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); 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 024f32474562..586e2320a808 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 @@ -62,7 +62,7 @@ public void createUser(User body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/user").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -93,7 +93,7 @@ public void createUsersWithArrayInput(List body) throws RestClientExceptio } String path = UriComponentsBuilder.fromPath("/user/createWithArray").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -124,7 +124,7 @@ public void createUsersWithListInput(List body) throws RestClientException } String path = UriComponentsBuilder.fromPath("/user/createWithList").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -159,7 +159,7 @@ public void deleteUser(String username) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("username", username); String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -196,7 +196,7 @@ public User getUserByName(String username) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("username", username); String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -237,11 +237,11 @@ public String loginUser(String username, String password) throws RestClientExcep } String path = UriComponentsBuilder.fromPath("/user/login").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); - + queryParams.putAll(apiClient.parameterToMultiValueMap(null, "username", username)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "password", password)); @@ -267,7 +267,7 @@ public void logoutUser() throws RestClientException { Object postBody = null; String path = UriComponentsBuilder.fromPath("/user/logout").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -308,7 +308,7 @@ public void updateUser(String username, User body) throws RestClientException { final Map uriVariables = new HashMap(); uriVariables.put("username", username); String path = UriComponentsBuilder.fromPath("/user/{username}").buildAndExpand(uriVariables).toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap();