diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache index 54f2b14573b..8bcaa33a3f0 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache @@ -91,9 +91,6 @@ public class ApiClient { private RestTemplate restTemplate; private Map authentications; - - private HttpStatus statusCode; - private MultiValueMap responseHeaders; private DateFormat dateFormat; @@ -146,22 +143,6 @@ public class ApiClient { return this; } - /** - * Gets the status code of the previous request - * @return HttpStatus the status code - */ - public HttpStatus getStatusCode() { - return statusCode; - } - - /** - * Gets the response headers of the previous request - * @return MultiValueMap a map of response headers - */ - public MultiValueMap getResponseHeaders() { - return responseHeaders; - } - /** * Get authentications (key: authentication name, value: authentication). * @return Map the currently configured authentication types @@ -520,9 +501,9 @@ public class ApiClient { * @param contentType The request's Content-Type header * @param authNames The authentications to apply * @param returnType The return type into which to deserialize the response - * @return The response body in chosen type + * @return ResponseEntity<T> The response of the chosen type */ - 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 { + public ResponseEntity 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); @@ -544,20 +525,12 @@ public class ApiClient { RequestEntity requestEntity = requestBuilder.body(selectBody(body, formParams, contentType)); ResponseEntity responseEntity = restTemplate.exchange(requestEntity, returnType); - - statusCode = responseEntity.getStatusCode(); - responseHeaders = responseEntity.getHeaders(); - if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) { - return null; - } else if (responseEntity.getStatusCode().is2xxSuccessful()) { - if (returnType == null) { - return null; - } - return responseEntity.getBody(); + if (responseEntity.getStatusCode().is2xxSuccessful()) { + return responseEntity; } else { // The error handler built into the RestTemplate should handle 400 and 500 series errors. - throw new RestClientException("API returned " + statusCode + " and it wasn't handled by the RestTemplate error handler"); + throw new RestClientException("API returned " + responseEntity.getStatusCode() + " and it wasn't handled by the RestTemplate error handler"); } } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/api.mustache index f48180f4381..2ee09d7df7c 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/api.mustache @@ -23,6 +23,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; {{>generatedAnnotation}} @Component("{{package}}.{{classname}}") @@ -51,16 +52,53 @@ public class {{classname}} { /** * {{summary}} * {{notes}} -{{#responses}} *

{{code}}{{#message}} - {{message}}{{/message}} -{{/responses}}{{#allParams}} * @param {{paramName}} {{description}}{{^description}}The {{paramName}} parameter{{/description}} -{{/allParams}}{{#returnType}} * @return {{returnType}} -{{/returnType}} * @throws RestClientException if an error occurs while attempting to invoke the API -{{#externalDocs}} - * {{description}} - * @see {{summary}} Documentation -{{/externalDocs}} + {{#responses}} + *

{{code}}{{#message}} - {{message}}{{/message}} + {{/responses}} + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + {{/allParams}} + {{#returnType}} + * @return {{returnType}} + {{/returnType}} + * @throws RestClientException if an error occurs while attempting to invoke the API + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws RestClientException { + {{#returnType}} + return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}).getBody(); + {{/returnType}} + {{^returnType}} + {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + {{/returnType}} + } + + /** + * {{summary}} + * {{notes}} + {{#responses}} + *

{{code}}{{#message}} - {{message}}{{/message}} + {{/responses}} + {{#allParams}} + * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} + {{/allParams}} + * @return ResponseEntity<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}> + * @throws RestClientException if an error occurs while attempting to invoke the API + {{#externalDocs}} + * {{description}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public ResponseEntity<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws RestClientException { Object {{localVariablePrefix}}postBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; {{#allParams}}{{#required}} // verify the required parameter '{{paramName}}' is set @@ -72,18 +110,18 @@ public class {{classname}} { final Map uriVariables = new HashMap();{{#pathParams}} uriVariables.put("{{baseName}}", {{{paramName}}});{{/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()){{/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}} @@ -100,7 +138,7 @@ public class {{classname}} { String[] {{localVariablePrefix}}authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; {{#returnType}}ParameterizedTypeReference<{{{returnType}}}> {{localVariablePrefix}}returnType = new ParameterizedTypeReference<{{{returnType}}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference {{localVariablePrefix}}returnType = new ParameterizedTypeReference() {};{{/returnType}} - {{#returnType}}return {{/returnType}}{{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, HttpMethod.{{httpMethod}}, {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, {{localVariablePrefix}}returnType); + return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}path, HttpMethod.{{httpMethod}}, {{localVariablePrefix}}queryParams, {{localVariablePrefix}}postBody, {{localVariablePrefix}}headerParams, {{localVariablePrefix}}formParams, {{localVariablePrefix}}accept, {{localVariablePrefix}}contentType, {{localVariablePrefix}}authNames, {{localVariablePrefix}}returnType); } {{/operation}} } diff --git a/samples/client/petstore/java/jersey2/.swagger-codegen/VERSION b/samples/client/petstore/java/jersey2/.swagger-codegen/VERSION index 9bc1c54fc94..bba5a87afd0 100644 --- a/samples/client/petstore/java/jersey2/.swagger-codegen/VERSION +++ b/samples/client/petstore/java/jersey2/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.8-SNAPSHOT \ No newline at end of file +2.4.9-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate/.swagger-codegen/VERSION b/samples/client/petstore/java/resttemplate/.swagger-codegen/VERSION index 9bc1c54fc94..bba5a87afd0 100644 --- a/samples/client/petstore/java/resttemplate/.swagger-codegen/VERSION +++ b/samples/client/petstore/java/resttemplate/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.8-SNAPSHOT \ No newline at end of file +2.4.9-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/ApiClient.java index b905f6a27c4..838f2ddc87b 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/ApiClient.java @@ -80,9 +80,6 @@ private String collectionToString(Collection collection) private RestTemplate restTemplate; private Map authentications; - - private HttpStatus statusCode; - private MultiValueMap responseHeaders; private DateFormat dateFormat; @@ -136,22 +133,6 @@ public ApiClient setBasePath(String basePath) { return this; } - /** - * Gets the status code of the previous request - * @return HttpStatus the status code - */ - public HttpStatus getStatusCode() { - return statusCode; - } - - /** - * Gets the response headers of the previous request - * @return MultiValueMap a map of response headers - */ - public MultiValueMap getResponseHeaders() { - return responseHeaders; - } - /** * Get authentications (key: authentication name, value: authentication). * @return Map the currently configured authentication types @@ -508,9 +489,9 @@ protected Object selectBody(Object obj, MultiValueMap formParams * @param contentType The request's Content-Type header * @param authNames The authentications to apply * @param returnType The return type into which to deserialize the response - * @return The response body in chosen type + * @return ResponseEntity<T> The response of the chosen type */ - 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 { + public ResponseEntity 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); @@ -532,20 +513,12 @@ public 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(); - if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) { - return null; - } else if (responseEntity.getStatusCode().is2xxSuccessful()) { - if (returnType == null) { - return null; - } - return responseEntity.getBody(); + if (responseEntity.getStatusCode().is2xxSuccessful()) { + return responseEntity; } else { // The error handler built into the RestTemplate should handle 400 and 500 series errors. - throw new RestClientException("API returned " + statusCode + " and it wasn't handled by the RestTemplate error handler"); + throw new RestClientException("API returned " + responseEntity.getStatusCode() + " and it wasn't handled by the RestTemplate error handler"); } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/AnotherFakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/AnotherFakeApi.java index 6992e1f5f42..68088d97f3d 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/AnotherFakeApi.java @@ -22,6 +22,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; @Component("io.swagger.client.api.AnotherFakeApi") @@ -49,11 +50,23 @@ public void setApiClient(ApiClient apiClient) { * To test special tags * To test special tags *

200 - successful operation - * @param body client model + * @param body client model (required) * @return Client * @throws RestClientException if an error occurs while attempting to invoke the API */ public Client testSpecialTags(Client body) throws RestClientException { + return testSpecialTagsWithHttpInfo(body).getBody(); + } + + /** + * To test special tags + * To test special tags + *

200 - successful operation + * @param body client model (required) + * @return ResponseEntity<Client> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testSpecialTagsWithHttpInfo(Client body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -62,7 +75,7 @@ public Client testSpecialTags(Client body) throws RestClientException { } String path = UriComponentsBuilder.fromPath("/another-fake/dummy").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/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java index 5708ef2509e..acb05acdf2d 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java @@ -27,6 +27,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; @Component("io.swagger.client.api.FakeApi") @@ -54,15 +55,27 @@ public void setApiClient(ApiClient apiClient) { * * Test serialization of outer boolean types *

200 - Output boolean - * @param body Input boolean as post body + * @param body Input boolean as post body (optional) * @return Boolean * @throws RestClientException if an error occurs while attempting to invoke the API */ public Boolean fakeOuterBooleanSerialize(Boolean body) throws RestClientException { + return fakeOuterBooleanSerializeWithHttpInfo(body).getBody(); + } + + /** + * + * Test serialization of outer boolean types + *

200 - Output boolean + * @param body Input boolean as post body (optional) + * @return ResponseEntity<Boolean> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws RestClientException { 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(); @@ -81,15 +94,27 @@ public Boolean fakeOuterBooleanSerialize(Boolean body) throws RestClientExceptio * * Test serialization of object with outer number type *

200 - Output composite - * @param body Input composite as post body + * @param body Input composite as post body (optional) * @return OuterComposite * @throws RestClientException if an error occurs while attempting to invoke the API */ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws RestClientException { + return fakeOuterCompositeSerializeWithHttpInfo(body).getBody(); + } + + /** + * + * Test serialization of object with outer number type + *

200 - Output composite + * @param body Input composite as post body (optional) + * @return ResponseEntity<OuterComposite> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws RestClientException { 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(); @@ -108,15 +133,27 @@ public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws Re * * Test serialization of outer number types *

200 - Output number - * @param body Input number as post body + * @param body Input number as post body (optional) * @return BigDecimal * @throws RestClientException if an error occurs while attempting to invoke the API */ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws RestClientException { + return fakeOuterNumberSerializeWithHttpInfo(body).getBody(); + } + + /** + * + * Test serialization of outer number types + *

200 - Output number + * @param body Input number as post body (optional) + * @return ResponseEntity<BigDecimal> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws RestClientException { 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(); @@ -135,15 +172,27 @@ public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws RestClientExc * * Test serialization of outer string types *

200 - Output string - * @param body Input string as post body + * @param body Input string as post body (optional) * @return String * @throws RestClientException if an error occurs while attempting to invoke the API */ public String fakeOuterStringSerialize(String body) throws RestClientException { + return fakeOuterStringSerializeWithHttpInfo(body).getBody(); + } + + /** + * + * Test serialization of outer string types + *

200 - Output string + * @param body Input string as post body (optional) + * @return ResponseEntity<String> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity fakeOuterStringSerializeWithHttpInfo(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(); @@ -162,11 +211,24 @@ public String fakeOuterStringSerialize(String body) throws RestClientException { * * *

200 - Success - * @param body The body parameter - * @param query The query parameter + * @param body (required) + * @param query (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void testBodyWithQueryParams(User body, String query) throws RestClientException { + testBodyWithQueryParamsWithHttpInfo(body, query); + } + + /** + * + * + *

200 - Success + * @param body (required) + * @param query (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testBodyWithQueryParamsWithHttpInfo(User body, String query) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -180,11 +242,11 @@ public void testBodyWithQueryParams(User body, String query) 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 = { }; @@ -197,17 +259,29 @@ public void testBodyWithQueryParams(User body, String query) throws RestClientEx String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * To test \"client\" model * To test \"client\" model *

200 - successful operation - * @param body client model + * @param body client model (required) * @return Client * @throws RestClientException if an error occurs while attempting to invoke the API */ public Client testClientModel(Client body) throws RestClientException { + return testClientModelWithHttpInfo(body).getBody(); + } + + /** + * To test \"client\" model + * To test \"client\" model + *

200 - successful operation + * @param body client model (required) + * @return ResponseEntity<Client> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testClientModelWithHttpInfo(Client body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -216,7 +290,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(); @@ -240,23 +314,49 @@ public Client testClientModel(Client body) throws RestClientException { * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *

400 - Invalid username supplied *

404 - User not found - * @param number None - * @param _double None - * @param patternWithoutDelimiter None - * @param _byte None - * @param integer None - * @param int32 None - * @param int64 None - * @param _float None - * @param string None - * @param binary None - * @param date None - * @param dateTime None - * @param password None - * @param paramCallback None + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws RestClientException { + testEndpointParametersWithHttpInfo(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback); + } + + /** + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + *

400 - Invalid username supplied + *

404 - User not found + * @param number None (required) + * @param _double None (required) + * @param patternWithoutDelimiter None (required) + * @param _byte None (required) + * @param integer None (optional) + * @param int32 None (optional) + * @param int64 None (optional) + * @param _float None (optional) + * @param string None (optional) + * @param binary None (optional) + * @param date None (optional) + * @param dateTime None (optional) + * @param password None (optional) + * @param paramCallback None (optional) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testEndpointParametersWithHttpInfo(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback) throws RestClientException { Object postBody = null; // verify the required parameter 'number' is set @@ -280,11 +380,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) @@ -326,41 +426,61 @@ public void testEndpointParameters(BigDecimal number, Double _double, String pat String[] authNames = new String[] { "http_basic_test" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * To test enum parameters * To test enum parameters *

400 - Invalid request *

404 - Not found - * @param enumFormStringArray Form parameter enum test (string array) - * @param enumFormString Form parameter enum test (string) - * @param enumHeaderStringArray Header parameter enum test (string array) - * @param enumHeaderString Header parameter enum test (string) - * @param enumQueryStringArray Query parameter enum test (string array) - * @param enumQueryString Query parameter enum test (string) - * @param enumQueryInteger Query parameter enum test (double) - * @param enumQueryDouble Query parameter enum test (double) + * @param enumFormStringArray Form parameter enum test (string array) (optional) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void testEnumParameters(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) throws RestClientException { + testEnumParametersWithHttpInfo(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble); + } + + /** + * To test enum parameters + * To test enum parameters + *

400 - Invalid request + *

404 - Not found + * @param enumFormStringArray Form parameter enum test (string array) (optional) + * @param enumFormString Form parameter enum test (string) (optional, default to -efg) + * @param enumHeaderStringArray Header parameter enum test (string array) (optional) + * @param enumHeaderString Header parameter enum test (string) (optional, default to -efg) + * @param enumQueryStringArray Query parameter enum test (string array) (optional) + * @param enumQueryString Query parameter enum test (string) (optional, default to -efg) + * @param enumQueryInteger Query parameter enum test (double) (optional) + * @param enumQueryDouble Query parameter enum test (double) (optional) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testEnumParametersWithHttpInfo(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) throws RestClientException { 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()), "enum_query_string_array", enumQueryStringArray)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_string", enumQueryString)); queryParams.putAll(apiClient.parameterToMultiValueMap(null, "enum_query_integer", enumQueryInteger)); - + 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) @@ -380,16 +500,28 @@ public void testEnumParameters(List enumFormStringArray, String enumForm String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * test inline additionalProperties * *

200 - successful operation - * @param param request body + * @param param request body (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void testInlineAdditionalProperties(Object param) throws RestClientException { + testInlineAdditionalPropertiesWithHttpInfo(param); + } + + /** + * test inline additionalProperties + * + *

200 - successful operation + * @param param request body (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testInlineAdditionalPropertiesWithHttpInfo(Object param) throws RestClientException { Object postBody = param; // verify the required parameter 'param' is set @@ -398,7 +530,7 @@ public void testInlineAdditionalProperties(Object param) throws RestClientExcept } String path = UriComponentsBuilder.fromPath("/fake/inline-additionalProperties").build().toUriString(); - + final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap formParams = new LinkedMultiValueMap(); @@ -413,17 +545,30 @@ public void testInlineAdditionalProperties(Object param) throws RestClientExcept String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * test json serialization of form data * *

200 - successful operation - * @param param field1 - * @param param2 field2 + * @param param field1 (required) + * @param param2 field2 (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void testJsonFormData(String param, String param2) throws RestClientException { + testJsonFormDataWithHttpInfo(param, param2); + } + + /** + * test json serialization of form data + * + *

200 - successful operation + * @param param field1 (required) + * @param param2 field2 (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testJsonFormDataWithHttpInfo(String param, String param2) throws RestClientException { Object postBody = null; // verify the required parameter 'param' is set @@ -437,11 +582,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) @@ -457,6 +602,6 @@ public void testJsonFormData(String param, String param2) throws RestClientExcep String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } } diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java index acfe3eaff57..2cc0aa2ce66 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeClassnameTags123Api.java @@ -22,6 +22,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; @Component("io.swagger.client.api.FakeClassnameTags123Api") @@ -49,11 +50,23 @@ public void setApiClient(ApiClient apiClient) { * To test class name in snake case * To test class name in snake case *

200 - successful operation - * @param body client model + * @param body client model (required) * @return Client * @throws RestClientException if an error occurs while attempting to invoke the API */ public Client testClassname(Client body) throws RestClientException { + return testClassnameWithHttpInfo(body).getBody(); + } + + /** + * To test class name in snake case + * To test class name in snake case + *

200 - successful operation + * @param body client model (required) + * @return ResponseEntity<Client> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity testClassnameWithHttpInfo(Client body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -62,11 +75,11 @@ 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(); - + final String[] accepts = { diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/PetApi.java index 0d8436ccc63..f301d37be46 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/PetApi.java @@ -24,6 +24,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; @Component("io.swagger.client.api.PetApi") @@ -51,10 +52,22 @@ public void setApiClient(ApiClient apiClient) { * Add a new pet to the store * *

405 - Invalid input - * @param body Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void addPet(Pet body) throws RestClientException { + addPetWithHttpInfo(body); + } + + /** + * Add a new pet to the store + * + *

405 - Invalid input + * @param body Pet object that needs to be added to the store (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity addPetWithHttpInfo(Pet body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -63,7 +76,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(); @@ -80,17 +93,30 @@ public void addPet(Pet body) throws RestClientException { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Deletes a pet * *

400 - Invalid pet value - * @param petId Pet id to delete - * @param apiKey The apiKey parameter + * @param petId Pet id to delete (required) + * @param apiKey (optional) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void deletePet(Long petId, String apiKey) throws RestClientException { + deletePetWithHttpInfo(petId, apiKey); + } + + /** + * Deletes a pet + * + *

400 - Invalid pet value + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity deletePetWithHttpInfo(Long petId, String apiKey) throws RestClientException { Object postBody = null; // verify the required parameter 'petId' is set @@ -102,11 +128,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)); @@ -120,18 +146,31 @@ public void deletePet(Long petId, String apiKey) throws RestClientException { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Finds Pets by status * Multiple status values can be provided with comma separated strings *

200 - successful operation *

400 - Invalid status value - * @param status Status values that need to be considered for filter + * @param status Status values that need to be considered for filter (required) * @return List<Pet> * @throws RestClientException if an error occurs while attempting to invoke the API */ public List findPetsByStatus(List status) throws RestClientException { + return findPetsByStatusWithHttpInfo(status).getBody(); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + *

200 - successful operation + *

400 - Invalid status value + * @param status Status values that need to be considered for filter (required) + * @return ResponseEntity<List<Pet>> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity> findPetsByStatusWithHttpInfo(List status) throws RestClientException { Object postBody = null; // verify the required parameter 'status' is set @@ -140,11 +179,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()), "status", status)); final String[] accepts = { @@ -164,11 +203,26 @@ public List findPetsByStatus(List status) throws RestClientExceptio * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. *

200 - successful operation *

400 - Invalid tag value - * @param tags Tags to filter by + * @param tags Tags to filter by (required) * @return List<Pet> * @throws RestClientException if an error occurs while attempting to invoke the API */ + @Deprecated public List findPetsByTags(List tags) throws RestClientException { + return findPetsByTagsWithHttpInfo(tags).getBody(); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + *

200 - successful operation + *

400 - Invalid tag value + * @param tags Tags to filter by (required) + * @return ResponseEntity<List<Pet>> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + @Deprecated + public ResponseEntity> findPetsByTagsWithHttpInfo(List tags) throws RestClientException { Object postBody = null; // verify the required parameter 'tags' is set @@ -177,11 +231,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()), "tags", tags)); final String[] accepts = { @@ -202,11 +256,25 @@ public List findPetsByTags(List tags) throws RestClientException { *

200 - successful operation *

400 - Invalid ID supplied *

404 - Pet not found - * @param petId ID of pet to return + * @param petId ID of pet to return (required) * @return Pet * @throws RestClientException if an error occurs while attempting to invoke the API */ public Pet getPetById(Long petId) throws RestClientException { + return getPetByIdWithHttpInfo(petId).getBody(); + } + + /** + * Find pet by ID + * Returns a single pet + *

200 - successful operation + *

400 - Invalid ID supplied + *

404 - Pet not found + * @param petId ID of pet to return (required) + * @return ResponseEntity<Pet> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity getPetByIdWithHttpInfo(Long petId) throws RestClientException { Object postBody = null; // verify the required parameter 'petId' is set @@ -218,7 +286,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(); @@ -241,10 +309,24 @@ public Pet getPetById(Long petId) throws RestClientException { *

400 - Invalid ID supplied *

404 - Pet not found *

405 - Validation exception - * @param body Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void updatePet(Pet body) throws RestClientException { + updatePetWithHttpInfo(body); + } + + /** + * Update an existing pet + * + *

400 - Invalid ID supplied + *

404 - Pet not found + *

405 - Validation exception + * @param body Pet object that needs to be added to the store (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity updatePetWithHttpInfo(Pet body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -253,7 +335,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(); @@ -270,18 +352,32 @@ public void updatePet(Pet body) throws RestClientException { String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Updates a pet in the store with form data * *

405 - Invalid input - * @param petId ID of pet that needs to be updated - * @param name Updated name of the pet - * @param status Updated status of the pet + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void updatePetWithForm(Long petId, String name, String status) throws RestClientException { + updatePetWithFormWithHttpInfo(petId, name, status); + } + + /** + * Updates a pet in the store with form data + * + *

405 - Invalid input + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity updatePetWithFormWithHttpInfo(Long petId, String name, String status) throws RestClientException { Object postBody = null; // verify the required parameter 'petId' is set @@ -293,11 +389,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) @@ -315,19 +411,33 @@ public void updatePetWithForm(Long petId, String name, String status) throws Res String[] authNames = new String[] { "petstore_auth" }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * uploads an image * *

200 - successful operation - * @param petId ID of pet to update - * @param additionalMetadata Additional data to pass to server - * @param file file to upload + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param file file to upload (optional) * @return ModelApiResponse * @throws RestClientException if an error occurs while attempting to invoke the API */ public ModelApiResponse uploadFile(Long petId, String additionalMetadata, File file) throws RestClientException { + return uploadFileWithHttpInfo(petId, additionalMetadata, file).getBody(); + } + + /** + * uploads an image + * + *

200 - successful operation + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param file file to upload (optional) + * @return ResponseEntity<ModelApiResponse> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws RestClientException { Object postBody = null; // verify the required parameter 'petId' is set @@ -339,11 +449,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) diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/StoreApi.java index bfe4173e279..0110025181b 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/StoreApi.java @@ -22,6 +22,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; @Component("io.swagger.client.api.StoreApi") @@ -50,10 +51,23 @@ public void setApiClient(ApiClient apiClient) { * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors *

400 - Invalid ID supplied *

404 - Order not found - * @param orderId ID of the order that needs to be deleted + * @param orderId ID of the order that needs to be deleted (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void deleteOrder(String orderId) throws RestClientException { + deleteOrderWithHttpInfo(orderId); + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + *

400 - Invalid ID supplied + *

404 - Order not found + * @param orderId ID of the order that needs to be deleted (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity deleteOrderWithHttpInfo(String orderId) throws RestClientException { Object postBody = null; // verify the required parameter 'orderId' is set @@ -65,7 +79,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(); @@ -80,7 +94,7 @@ public void deleteOrder(String orderId) throws RestClientException { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Returns pet inventories by status @@ -90,10 +104,21 @@ public void deleteOrder(String orderId) throws RestClientException { * @throws RestClientException if an error occurs while attempting to invoke the API */ public Map getInventory() throws RestClientException { + return getInventoryWithHttpInfo().getBody(); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + *

200 - successful operation + * @return ResponseEntity<Map<String, Integer>> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity> getInventoryWithHttpInfo() 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(); @@ -116,11 +141,25 @@ public Map getInventory() throws RestClientException { *

200 - successful operation *

400 - Invalid ID supplied *

404 - Order not found - * @param orderId ID of pet that needs to be fetched + * @param orderId ID of pet that needs to be fetched (required) * @return Order * @throws RestClientException if an error occurs while attempting to invoke the API */ public Order getOrderById(Long orderId) throws RestClientException { + return getOrderByIdWithHttpInfo(orderId).getBody(); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + *

200 - successful operation + *

400 - Invalid ID supplied + *

404 - Order not found + * @param orderId ID of pet that needs to be fetched (required) + * @return ResponseEntity<Order> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity getOrderByIdWithHttpInfo(Long orderId) throws RestClientException { Object postBody = null; // verify the required parameter 'orderId' is set @@ -132,7 +171,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(); @@ -154,11 +193,24 @@ public Order getOrderById(Long orderId) throws RestClientException { * *

200 - successful operation *

400 - Invalid Order - * @param body order placed for purchasing the pet + * @param body order placed for purchasing the pet (required) * @return Order * @throws RestClientException if an error occurs while attempting to invoke the API */ public Order placeOrder(Order body) throws RestClientException { + return placeOrderWithHttpInfo(body).getBody(); + } + + /** + * Place an order for a pet + * + *

200 - successful operation + *

400 - Invalid Order + * @param body order placed for purchasing the pet (required) + * @return ResponseEntity<Order> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity placeOrderWithHttpInfo(Order body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -167,7 +219,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/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/UserApi.java index 019d802e215..9037514f136 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/UserApi.java @@ -22,6 +22,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; @Component("io.swagger.client.api.UserApi") @@ -49,10 +50,22 @@ public void setApiClient(ApiClient apiClient) { * Create user * This can only be done by the logged in user. *

0 - successful operation - * @param body Created user object + * @param body Created user object (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void createUser(User body) throws RestClientException { + createUserWithHttpInfo(body); + } + + /** + * Create user + * This can only be done by the logged in user. + *

0 - successful operation + * @param body Created user object (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity createUserWithHttpInfo(User body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -61,7 +74,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(); @@ -76,16 +89,28 @@ public void createUser(User body) throws RestClientException { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Creates list of users with given input array * *

0 - successful operation - * @param body List of user object + * @param body List of user object (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void createUsersWithArrayInput(List body) throws RestClientException { + createUsersWithArrayInputWithHttpInfo(body); + } + + /** + * Creates list of users with given input array + * + *

0 - successful operation + * @param body List of user object (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity createUsersWithArrayInputWithHttpInfo(List body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -94,7 +119,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(); @@ -109,16 +134,28 @@ public void createUsersWithArrayInput(List body) throws RestClientExceptio String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Creates list of users with given input array * *

0 - successful operation - * @param body List of user object + * @param body List of user object (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void createUsersWithListInput(List body) throws RestClientException { + createUsersWithListInputWithHttpInfo(body); + } + + /** + * Creates list of users with given input array + * + *

0 - successful operation + * @param body List of user object (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity createUsersWithListInputWithHttpInfo(List body) throws RestClientException { Object postBody = body; // verify the required parameter 'body' is set @@ -127,7 +164,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(); @@ -142,17 +179,30 @@ public void createUsersWithListInput(List body) throws RestClientException String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Delete user * This can only be done by the logged in user. *

400 - Invalid username supplied *

404 - User not found - * @param username The name that needs to be deleted + * @param username The name that needs to be deleted (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void deleteUser(String username) throws RestClientException { + deleteUserWithHttpInfo(username); + } + + /** + * Delete user + * This can only be done by the logged in user. + *

400 - Invalid username supplied + *

404 - User not found + * @param username The name that needs to be deleted (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity deleteUserWithHttpInfo(String username) throws RestClientException { Object postBody = null; // verify the required parameter 'username' is set @@ -164,7 +214,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(); @@ -179,7 +229,7 @@ public void deleteUser(String username) throws RestClientException { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.DELETE, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Get user by user name @@ -187,11 +237,25 @@ public void deleteUser(String username) throws RestClientException { *

200 - successful operation *

400 - Invalid username supplied *

404 - User not found - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. (required) * @return User * @throws RestClientException if an error occurs while attempting to invoke the API */ public User getUserByName(String username) throws RestClientException { + return getUserByNameWithHttpInfo(username).getBody(); + } + + /** + * Get user by user name + * + *

200 - successful operation + *

400 - Invalid username supplied + *

404 - User not found + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return ResponseEntity<User> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity getUserByNameWithHttpInfo(String username) throws RestClientException { Object postBody = null; // verify the required parameter 'username' is set @@ -203,7 +267,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(); @@ -225,12 +289,26 @@ public User getUserByName(String username) throws RestClientException { * *

200 - successful operation *

400 - Invalid username/password supplied - * @param username The user name for login - * @param password The password for login in clear text + * @param username The user name for login (required) + * @param password The password for login in clear text (required) * @return String * @throws RestClientException if an error occurs while attempting to invoke the API */ public String loginUser(String username, String password) throws RestClientException { + return loginUserWithHttpInfo(username, password).getBody(); + } + + /** + * Logs user into the system + * + *

200 - successful operation + *

400 - Invalid username/password supplied + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return ResponseEntity<String> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity loginUserWithHttpInfo(String username, String password) throws RestClientException { Object postBody = null; // verify the required parameter 'username' is set @@ -244,11 +322,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)); @@ -271,10 +349,21 @@ public String loginUser(String username, String password) throws RestClientExcep * @throws RestClientException if an error occurs while attempting to invoke the API */ public void logoutUser() throws RestClientException { + logoutUserWithHttpInfo(); + } + + /** + * Logs out current logged in user session + * + *

0 - successful operation + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity logoutUserWithHttpInfo() 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(); @@ -289,18 +378,32 @@ public void logoutUser() throws RestClientException { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } /** * Updated user * This can only be done by the logged in user. *

400 - Invalid user supplied *

404 - User not found - * @param username name that need to be deleted - * @param body Updated user object + * @param username name that need to be deleted (required) + * @param body Updated user object (required) * @throws RestClientException if an error occurs while attempting to invoke the API */ public void updateUser(String username, User body) throws RestClientException { + updateUserWithHttpInfo(username, body); + } + + /** + * Updated user + * This can only be done by the logged in user. + *

400 - Invalid user supplied + *

404 - User not found + * @param username name that need to be deleted (required) + * @param body Updated user object (required) + * @return ResponseEntity<Void> + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public ResponseEntity updateUserWithHttpInfo(String username, User body) throws RestClientException { Object postBody = body; // verify the required parameter 'username' is set @@ -317,7 +420,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(); @@ -332,6 +435,6 @@ public void updateUser(String username, User body) throws RestClientException { String[] authNames = new String[] { }; ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; - apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + return apiClient.invokeAPI(path, HttpMethod.PUT, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); } }