diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java index e34a582460f..c6234ea8824 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java @@ -389,8 +389,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen modelDocTemplateFiles.remove("model_doc.mustache"); apiDocTemplateFiles.remove("api_doc.mustache"); //Templates to decode response headers - supportingFiles.add(new SupportingFile("model/HttpResponse.mustache", modelsFolder, "HttpResponse.java")); - supportingFiles.add(new SupportingFile("JacksonResponseDecoder.mustache", invokerFolder, "JacksonResponseDecoder.java")); + supportingFiles.add(new SupportingFile("model/ApiResponse.mustache", modelsFolder, "ApiResponse.java")); + supportingFiles.add(new SupportingFile("ApiResponseDecoder.mustache", invokerFolder, "ApiResponseDecoder.java")); } if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || RETROFIT_2.equals(getLibrary()) || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || WEBCLIENT.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) { diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache index d85891ca4d7..5c4e78970ea 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiClient.mustache @@ -35,7 +35,7 @@ import feign.slf4j.Slf4jLogger; import {{invokerPackage}}.auth.HttpBasicAuth; import {{invokerPackage}}.auth.HttpBearerAuth; import {{invokerPackage}}.auth.ApiKeyAuth; -import {{invokerPackage}}.JacksonResponseDecoder; +import {{invokerPackage}}.ApiResponseDecoder; {{#hasOAuthMethods}} import {{invokerPackage}}.auth.ApiErrorDecoder; @@ -64,7 +64,7 @@ public class ApiClient { feignBuilder = Feign.builder() .client(new OkHttpClient()) .encoder(new FormEncoder(new JacksonEncoder(objectMapper))) - .decoder(new JacksonResponseDecoder(objectMapper)) + .decoder(new ApiResponseDecoder(objectMapper)) {{#hasOAuthMethods}} .errorDecoder(new ApiErrorDecoder()) .retryer(new Retryer.Default(0, 0, 2)) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/JacksonResponseDecoder.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiResponseDecoder.mustache similarity index 64% rename from modules/openapi-generator/src/main/resources/Java/libraries/feign/JacksonResponseDecoder.mustache rename to modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiResponseDecoder.mustache index 34f58cdd643..ef171de9430 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/JacksonResponseDecoder.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/ApiResponseDecoder.mustache @@ -12,26 +12,26 @@ import java.util.Collection; import java.util.Collections; import java.util.Map; -import {{modelPackage}}.HttpResponse; +import {{modelPackage}}.ApiResponse; -public class JacksonResponseDecoder extends JacksonDecoder { +public class ApiResponseDecoder extends JacksonDecoder { - public JacksonResponseDecoder(ObjectMapper mapper) { + public ApiResponseDecoder(ObjectMapper mapper) { super(mapper); } @Override public Object decode(Response response, Type type) throws IOException { Map> responseHeaders = Collections.unmodifiableMap(response.headers()); - //Detects if the type is an instance of the parameterized class HttpResponse + //Detects if the type is an instance of the parameterized class ApiResponse Type responseBodyType; - if (Types.getRawType(type).isAssignableFrom(HttpResponse.class)) { - //The HttpResponse class has a single type parameter, the Dto class itself + if (Types.getRawType(type).isAssignableFrom(ApiResponse.class)) { + //The ApiResponse class has a single type parameter, the Dto class itself responseBodyType = ((ParameterizedType) type).getActualTypeArguments()[0]; Object body = super.decode(response, responseBodyType); - return new HttpResponse(responseHeaders, body); + return new ApiResponse(response.status(), responseHeaders, body); } else { - //The response is not encapsulated in the HttpResponse, decode the Dto as normal + //The response is not encapsulated in the ApiResponse, decode the Dto as normal return super.decode(response, type); } } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/api.mustache index f31c17e7db6..c494070002d 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/api.mustache @@ -5,7 +5,7 @@ import {{invokerPackage}}.EncodingUtils; {{#legacyDates}} import {{invokerPackage}}.ParamExpander; {{/legacyDates}} -import {{modelPackage}}.HttpResponse; +import {{modelPackage}}.ApiResponse; {{#imports}}import {{import}}; {{/imports}} @@ -59,7 +59,7 @@ public interface {{classname}} extends ApiClient.Api { * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}} {{/allParams}} {{#returnType}} - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. {{/returnType}} {{#externalDocs}} * {{description}} @@ -79,7 +79,7 @@ public interface {{classname}} extends ApiClient.Api { "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}}, {{/-last}}{{/headerParams}} }) - HttpResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{nickname}}WithHttpInfo({{#allParams}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{nickname}}WithHttpInfo({{#allParams}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); {{#hasQueryParams}} @@ -164,7 +164,7 @@ public interface {{classname}} extends ApiClient.Api { "{{baseName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{^-last}}, {{/-last}}{{/headerParams}} }) - HttpResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{nickname}}WithHttpInfo({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map queryParams); + ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{nickname}}WithHttpInfo({{#allParams}}{{^isQueryParam}}{{^isBodyParam}}{{^legacyDates}}@Param("{{paramName}}") {{/legacyDates}}{{#legacyDates}}@Param(value="{{paramName}}", expander=ParamExpander.class) {{/legacyDates}}{{/isBodyParam}}{{{dataType}}} {{paramName}}, {{/isQueryParam}}{{/allParams}}@QueryMap(encoded=true) Map queryParams); /** diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/auth/ApiErrorDecoder.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/auth/ApiErrorDecoder.mustache index d3587925abf..da87f2563b1 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/auth/ApiErrorDecoder.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/auth/ApiErrorDecoder.mustache @@ -5,7 +5,7 @@ import feign.RetryableException; import feign.codec.ErrorDecoder; /** - * Error decoder that makes the HTTP 401 and 403 Retryable. Sometimes the 401 or 402 may indicate an expired token + * Error decoder that makes the HTTP 401 and 403 Retryable. Sometimes the 401 or 403 may indicate an expired token * All the other HTTP status are handled by the {@link feign.codec.ErrorDecoder.Default} decoder */ public class ApiErrorDecoder implements ErrorDecoder { diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/model/ApiResponse.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/model/ApiResponse.mustache new file mode 100644 index 00000000000..bc460dc59c0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/Java/libraries/feign/model/ApiResponse.mustache @@ -0,0 +1,43 @@ +package {{modelPackage}}; + +import java.util.Map; +import java.util.List; + +public class ApiResponse{ + + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } + +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/feign/model/HttpResponse.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/feign/model/HttpResponse.mustache deleted file mode 100644 index 172ac126d35..00000000000 --- a/modules/openapi-generator/src/main/resources/Java/libraries/feign/model/HttpResponse.mustache +++ /dev/null @@ -1,24 +0,0 @@ -package {{modelPackage}}; - -import java.util.Map; -import java.util.Collection; - -public class HttpResponse{ - - private Map> headers; - - private T body; - - public HttpResponse(Map> headers, T body) { - this.headers = headers; - this.body = body; - } - - public T getBody(){ - return body; - } - - public Map> getHeaders(){ - return headers; - } -} \ No newline at end of file diff --git a/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES b/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES index 14b7ee2fd7b..e228aa901f2 100644 --- a/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES +++ b/samples/client/petstore/java/feign-no-nullable/.openapi-generator/FILES @@ -14,9 +14,9 @@ pom.xml settings.gradle src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java +src/main/java/org/openapitools/client/ApiResponseDecoder.java src/main/java/org/openapitools/client/CustomInstantDeserializer.java src/main/java/org/openapitools/client/EncodingUtils.java -src/main/java/org/openapitools/client/JacksonResponseDecoder.java src/main/java/org/openapitools/client/ParamExpander.java src/main/java/org/openapitools/client/RFC3339DateFormat.java src/main/java/org/openapitools/client/ServerConfiguration.java @@ -46,6 +46,7 @@ src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java src/main/java/org/openapitools/client/model/Animal.java +src/main/java/org/openapitools/client/model/ApiResponse.java src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java src/main/java/org/openapitools/client/model/ArrayTest.java @@ -65,7 +66,6 @@ src/main/java/org/openapitools/client/model/EnumTest.java src/main/java/org/openapitools/client/model/FileSchemaTestClass.java src/main/java/org/openapitools/client/model/FormatTest.java src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java -src/main/java/org/openapitools/client/model/HttpResponse.java src/main/java/org/openapitools/client/model/MapTest.java src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java src/main/java/org/openapitools/client/model/Model200Response.java diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java index 231bab571be..ba2274d8fe0 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiClient.java @@ -22,7 +22,7 @@ import feign.slf4j.Slf4jLogger; import org.openapitools.client.auth.HttpBasicAuth; import org.openapitools.client.auth.HttpBearerAuth; import org.openapitools.client.auth.ApiKeyAuth; -import org.openapitools.client.JacksonResponseDecoder; +import org.openapitools.client.ApiResponseDecoder; import org.openapitools.client.auth.ApiErrorDecoder; import org.openapitools.client.auth.OAuth; @@ -49,7 +49,7 @@ public class ApiClient { feignBuilder = Feign.builder() .client(new OkHttpClient()) .encoder(new FormEncoder(new JacksonEncoder(objectMapper))) - .decoder(new JacksonResponseDecoder(objectMapper)) + .decoder(new ApiResponseDecoder(objectMapper)) .errorDecoder(new ApiErrorDecoder()) .retryer(new Retryer.Default(0, 0, 2)) .logger(new Slf4jLogger()); diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiResponseDecoder.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiResponseDecoder.java new file mode 100644 index 00000000000..d74d1d8768d --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/ApiResponseDecoder.java @@ -0,0 +1,38 @@ +package org.openapitools.client; + +import com.fasterxml.jackson.databind.ObjectMapper; +import feign.Response; +import feign.Types; +import feign.jackson.JacksonDecoder; + +import java.io.IOException; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import org.openapitools.client.model.ApiResponse; + +public class ApiResponseDecoder extends JacksonDecoder { + + public ApiResponseDecoder(ObjectMapper mapper) { + super(mapper); + } + + @Override + public Object decode(Response response, Type type) throws IOException { + Map> responseHeaders = Collections.unmodifiableMap(response.headers()); + //Detects if the type is an instance of the parameterized class ApiResponse + Type responseBodyType; + if (Types.getRawType(type).isAssignableFrom(ApiResponse.class)) { + //The ApiResponse class has a single type parameter, the Dto class itself + responseBodyType = ((ParameterizedType) type).getActualTypeArguments()[0]; + Object body = super.decode(response, responseBodyType); + return new ApiResponse(response.status(), responseHeaders, body); + } else { + //The response is not encapsulated in the ApiResponse, decode the Dto as normal + return super.decode(response, type); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/JacksonResponseDecoder.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/JacksonResponseDecoder.java index 4951d732f22..b3db8c605ab 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/JacksonResponseDecoder.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/JacksonResponseDecoder.java @@ -29,7 +29,7 @@ public class JacksonResponseDecoder extends JacksonDecoder { //The HttpResponse class has a single type parameter, the Dto class itself responseBodyType = ((ParameterizedType) type).getActualTypeArguments()[0]; Object body = super.decode(response, responseBodyType); - return new HttpResponse(responseHeaders, body); + return new HttpResponse(responseHeaders, body, response.status()); } else { //The response is not encapsulated in the HttpResponse, decode the Dto as normal return super.decode(response, type); diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index cb47437091f..db3647bf64d 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.Client; @@ -34,14 +34,14 @@ public interface AnotherFakeApi extends ApiClient.Api { * Similar to call123testSpecialTags but it also returns the http response headers . * To test special tags and operation ID starting with number * @param body client model (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("PATCH /another-fake/dummy") @Headers({ "Content-Type: application/json", "Accept: application/json", }) - HttpResponse call123testSpecialTagsWithHttpInfo(Client body); + ApiResponse call123testSpecialTagsWithHttpInfo(Client body); } diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeApi.java index a2d2628c113..3a9fb59c458 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import java.math.BigDecimal; import org.openapitools.client.model.Client; @@ -47,7 +47,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/xml", "Accept: application/json", }) - HttpResponse createXmlItemWithHttpInfo(XmlItem xmlItem); + ApiResponse createXmlItemWithHttpInfo(XmlItem xmlItem); @@ -69,14 +69,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterBooleanSerialize but it also returns the http response headers . * Test serialization of outer boolean types * @param body Input boolean as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/boolean") @Headers({ "Content-Type: */*", "Accept: */*", }) - HttpResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body); + ApiResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body); @@ -98,14 +98,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterCompositeSerialize but it also returns the http response headers . * Test serialization of object with outer number type * @param body Input composite as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/composite") @Headers({ "Content-Type: */*", "Accept: */*", }) - HttpResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body); + ApiResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body); @@ -127,14 +127,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterNumberSerialize but it also returns the http response headers . * Test serialization of outer number types * @param body Input number as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/number") @Headers({ "Content-Type: */*", "Accept: */*", }) - HttpResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body); + ApiResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body); @@ -156,14 +156,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterStringSerialize but it also returns the http response headers . * Test serialization of outer string types * @param body Input string as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/string") @Headers({ "Content-Type: */*", "Accept: */*", }) - HttpResponse fakeOuterStringSerializeWithHttpInfo(String body); + ApiResponse fakeOuterStringSerializeWithHttpInfo(String body); @@ -190,7 +190,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass body); + ApiResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass body); @@ -219,7 +219,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testBodyWithQueryParamsWithHttpInfo(@Param("query") String query, User body); + ApiResponse testBodyWithQueryParamsWithHttpInfo(@Param("query") String query, User body); /** @@ -261,7 +261,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testBodyWithQueryParamsWithHttpInfo(User body, @QueryMap(encoded=true) Map queryParams); + ApiResponse testBodyWithQueryParamsWithHttpInfo(User body, @QueryMap(encoded=true) Map queryParams); /** @@ -293,14 +293,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to testClientModel but it also returns the http response headers . * To test \"client\" model * @param body client model (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("PATCH /fake") @Headers({ "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testClientModelWithHttpInfo(Client body); + ApiResponse testClientModelWithHttpInfo(Client body); @@ -353,7 +353,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/x-www-form-urlencoded", "Accept: application/json", }) - HttpResponse testEndpointParametersWithHttpInfo(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback); + ApiResponse testEndpointParametersWithHttpInfo(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback); @@ -400,7 +400,7 @@ public interface FakeApi extends ApiClient.Api { "enum_header_string: {enumHeaderString}" }) - HttpResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString); + ApiResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString); /** @@ -460,7 +460,7 @@ public interface FakeApi extends ApiClient.Api { "enum_header_string: {enumHeaderString}" }) - HttpResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString, @QueryMap(encoded=true) Map queryParams); + ApiResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString, @QueryMap(encoded=true) Map queryParams); /** @@ -523,7 +523,7 @@ public interface FakeApi extends ApiClient.Api { "boolean_group: {booleanGroup}" }) - HttpResponse testGroupParametersWithHttpInfo(@Param("requiredStringGroup") Integer requiredStringGroup, @Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("requiredInt64Group") Long requiredInt64Group, @Param("stringGroup") Integer stringGroup, @Param("booleanGroup") Boolean booleanGroup, @Param("int64Group") Long int64Group); + ApiResponse testGroupParametersWithHttpInfo(@Param("requiredStringGroup") Integer requiredStringGroup, @Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("requiredInt64Group") Long requiredInt64Group, @Param("stringGroup") Integer stringGroup, @Param("booleanGroup") Boolean booleanGroup, @Param("int64Group") Long int64Group); /** @@ -577,7 +577,7 @@ public interface FakeApi extends ApiClient.Api { "boolean_group: {booleanGroup}" }) - HttpResponse testGroupParametersWithHttpInfo(@Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("booleanGroup") Boolean booleanGroup, @QueryMap(encoded=true) Map queryParams); + ApiResponse testGroupParametersWithHttpInfo(@Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("booleanGroup") Boolean booleanGroup, @QueryMap(encoded=true) Map queryParams); /** @@ -626,7 +626,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testInlineAdditionalPropertiesWithHttpInfo(Map param); + ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Map param); @@ -655,7 +655,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/x-www-form-urlencoded", "Accept: application/json", }) - HttpResponse testJsonFormDataWithHttpInfo(@Param("param") String param, @Param("param2") String param2); + ApiResponse testJsonFormDataWithHttpInfo(@Param("param") String param, @Param("param2") String param2); @@ -688,7 +688,7 @@ public interface FakeApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse testQueryParameterCollectionFormatWithHttpInfo(@Param("pipe") List pipe, @Param("ioutil") List ioutil, @Param("http") List http, @Param("url") List url, @Param("context") List context); + ApiResponse testQueryParameterCollectionFormatWithHttpInfo(@Param("pipe") List pipe, @Param("ioutil") List ioutil, @Param("http") List http, @Param("url") List url, @Param("context") List context); /** @@ -734,7 +734,7 @@ public interface FakeApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse testQueryParameterCollectionFormatWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse testQueryParameterCollectionFormatWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 2ba4d90bbe6..61aea1a853a 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.Client; @@ -34,14 +34,14 @@ public interface FakeClassnameTags123Api extends ApiClient.Api { * Similar to testClassname but it also returns the http response headers . * To test class name in snake case * @param body client model (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("PATCH /fake_classname_test") @Headers({ "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testClassnameWithHttpInfo(Client body); + ApiResponse testClassnameWithHttpInfo(Client body); } diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/PetApi.java index 634b3f36c7e..f94011fbe2d 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/PetApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import java.io.File; import org.openapitools.client.model.ModelApiResponse; @@ -42,7 +42,7 @@ public interface PetApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse addPetWithHttpInfo(Pet body); + ApiResponse addPetWithHttpInfo(Pet body); @@ -71,7 +71,7 @@ public interface PetApi extends ApiClient.Api { "Accept: application/json", "api_key: {apiKey}" }) - HttpResponse deletePetWithHttpInfo(@Param("petId") Long petId, @Param("apiKey") String apiKey); + ApiResponse deletePetWithHttpInfo(@Param("petId") Long petId, @Param("apiKey") String apiKey); @@ -92,13 +92,13 @@ public interface PetApi extends ApiClient.Api { * Similar to findPetsByStatus but it also returns the http response headers . * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /pet/findByStatus?status={status}") @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByStatusWithHttpInfo(@Param("status") List status); + ApiResponse> findPetsByStatusWithHttpInfo(@Param("status") List status); /** @@ -138,7 +138,7 @@ public interface PetApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByStatusWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse> findPetsByStatusWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** @@ -171,7 +171,7 @@ public interface PetApi extends ApiClient.Api { * Similar to findPetsByTags but it also returns the http response headers . * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. * @deprecated */ @Deprecated @@ -179,7 +179,7 @@ public interface PetApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByTagsWithHttpInfo(@Param("tags") Set tags); + ApiResponse> findPetsByTagsWithHttpInfo(@Param("tags") Set tags); /** @@ -223,7 +223,7 @@ public interface PetApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByTagsWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse> findPetsByTagsWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** @@ -254,13 +254,13 @@ public interface PetApi extends ApiClient.Api { * Similar to getPetById but it also returns the http response headers . * Returns a single pet * @param petId ID of pet to return (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /pet/{petId}") @Headers({ "Accept: application/json", }) - HttpResponse getPetByIdWithHttpInfo(@Param("petId") Long petId); + ApiResponse getPetByIdWithHttpInfo(@Param("petId") Long petId); @@ -287,7 +287,7 @@ public interface PetApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse updatePetWithHttpInfo(Pet body); + ApiResponse updatePetWithHttpInfo(Pet body); @@ -318,7 +318,7 @@ public interface PetApi extends ApiClient.Api { "Content-Type: application/x-www-form-urlencoded", "Accept: application/json", }) - HttpResponse updatePetWithFormWithHttpInfo(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status); + ApiResponse updatePetWithFormWithHttpInfo(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status); @@ -344,14 +344,14 @@ public interface PetApi extends ApiClient.Api { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /pet/{petId}/uploadImage") @Headers({ "Content-Type: multipart/form-data", "Accept: application/json", }) - HttpResponse uploadFileWithHttpInfo(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); + ApiResponse uploadFileWithHttpInfo(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); @@ -377,14 +377,14 @@ public interface PetApi extends ApiClient.Api { * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/{petId}/uploadImageWithRequiredFile") @Headers({ "Content-Type: multipart/form-data", "Accept: application/json", }) - HttpResponse uploadFileWithRequiredFileWithHttpInfo(@Param("petId") Long petId, @Param("requiredFile") File requiredFile, @Param("additionalMetadata") String additionalMetadata); + ApiResponse uploadFileWithRequiredFileWithHttpInfo(@Param("petId") Long petId, @Param("requiredFile") File requiredFile, @Param("additionalMetadata") String additionalMetadata); } diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/StoreApi.java index 8b01a453df5..9b821d4302d 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/StoreApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.Order; @@ -37,7 +37,7 @@ public interface StoreApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse deleteOrderWithHttpInfo(@Param("orderId") String orderId); + ApiResponse deleteOrderWithHttpInfo(@Param("orderId") String orderId); @@ -56,13 +56,13 @@ public interface StoreApi extends ApiClient.Api { * Returns pet inventories by status * Similar to getInventory but it also returns the http response headers . * Returns a map of status codes to quantities - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /store/inventory") @Headers({ "Accept: application/json", }) - HttpResponse> getInventoryWithHttpInfo(); + ApiResponse> getInventoryWithHttpInfo(); @@ -83,13 +83,13 @@ public interface StoreApi extends ApiClient.Api { * Similar to getOrderById but it also returns the http response headers . * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /store/order/{orderId}") @Headers({ "Accept: application/json", }) - HttpResponse getOrderByIdWithHttpInfo(@Param("orderId") Long orderId); + ApiResponse getOrderByIdWithHttpInfo(@Param("orderId") Long orderId); @@ -111,14 +111,14 @@ public interface StoreApi extends ApiClient.Api { * Similar to placeOrder but it also returns the http response headers . * * @param body order placed for purchasing the pet (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /store/order") @Headers({ "Content-Type: */*", "Accept: application/json", }) - HttpResponse placeOrderWithHttpInfo(Order body); + ApiResponse placeOrderWithHttpInfo(Order body); } diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/UserApi.java index d7467d0ce71..d97f8235c4d 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/api/UserApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.User; @@ -39,7 +39,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: */*", "Accept: application/json", }) - HttpResponse createUserWithHttpInfo(User body); + ApiResponse createUserWithHttpInfo(User body); @@ -66,7 +66,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: */*", "Accept: application/json", }) - HttpResponse createUsersWithArrayInputWithHttpInfo(List body); + ApiResponse createUsersWithArrayInputWithHttpInfo(List body); @@ -93,7 +93,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: */*", "Accept: application/json", }) - HttpResponse createUsersWithListInputWithHttpInfo(List body); + ApiResponse createUsersWithListInputWithHttpInfo(List body); @@ -118,7 +118,7 @@ public interface UserApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse deleteUserWithHttpInfo(@Param("username") String username); + ApiResponse deleteUserWithHttpInfo(@Param("username") String username); @@ -139,13 +139,13 @@ public interface UserApi extends ApiClient.Api { * Similar to getUserByName but it also returns the http response headers . * * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /user/{username}") @Headers({ "Accept: application/json", }) - HttpResponse getUserByNameWithHttpInfo(@Param("username") String username); + ApiResponse getUserByNameWithHttpInfo(@Param("username") String username); @@ -168,13 +168,13 @@ public interface UserApi extends ApiClient.Api { * * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /user/login?username={username}&password={password}") @Headers({ "Accept: application/json", }) - HttpResponse loginUserWithHttpInfo(@Param("username") String username, @Param("password") String password); + ApiResponse loginUserWithHttpInfo(@Param("username") String username, @Param("password") String password); /** @@ -216,7 +216,7 @@ public interface UserApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse loginUserWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse loginUserWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** @@ -253,7 +253,7 @@ public interface UserApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse logoutUserWithHttpInfo(); + ApiResponse logoutUserWithHttpInfo(); @@ -282,7 +282,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: */*", "Accept: application/json", }) - HttpResponse updateUserWithHttpInfo(@Param("username") String username, User body); + ApiResponse updateUserWithHttpInfo(@Param("username") String username, User body); } diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java index 4ddfc678e92..2a33ff9434a 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java @@ -5,7 +5,7 @@ import feign.RetryableException; import feign.codec.ErrorDecoder; /** - * Error decoder that makes the HTTP 401 and 403 Retryable. Sometimes the 401 or 402 may indicate an expired token + * Error decoder that makes the HTTP 401 and 403 Retryable. Sometimes the 401 or 403 may indicate an expired token * All the other HTTP status are handled by the {@link feign.codec.ErrorDecoder.Default} decoder */ public class ApiErrorDecoder implements ErrorDecoder { diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ApiResponse.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ApiResponse.java new file mode 100644 index 00000000000..a0d44e724c5 --- /dev/null +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/ApiResponse.java @@ -0,0 +1,43 @@ +package org.openapitools.client.model; + +import java.util.Map; +import java.util.List; + +public class ApiResponse{ + + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/HttpResponse.java b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/HttpResponse.java index d4f45014034..f0e57a0af73 100644 --- a/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/HttpResponse.java +++ b/samples/client/petstore/java/feign-no-nullable/src/main/java/org/openapitools/client/model/HttpResponse.java @@ -9,9 +9,12 @@ public class HttpResponse{ private T body; - public HttpResponse(Map> headers, T body) { + private int status; + + public HttpResponse(Map> headers, T body, int status) { this.headers = headers; this.body = body; + this.status = status; } public T getBody(){ @@ -21,4 +24,8 @@ public class HttpResponse{ public Map> getHeaders(){ return headers; } + + public int getStatus(){ + return status; + } } \ No newline at end of file diff --git a/samples/client/petstore/java/feign/.openapi-generator/FILES b/samples/client/petstore/java/feign/.openapi-generator/FILES index defc79334ec..9dd7f3f9097 100644 --- a/samples/client/petstore/java/feign/.openapi-generator/FILES +++ b/samples/client/petstore/java/feign/.openapi-generator/FILES @@ -14,9 +14,9 @@ pom.xml settings.gradle src/main/AndroidManifest.xml src/main/java/org/openapitools/client/ApiClient.java +src/main/java/org/openapitools/client/ApiResponseDecoder.java src/main/java/org/openapitools/client/CustomInstantDeserializer.java src/main/java/org/openapitools/client/EncodingUtils.java -src/main/java/org/openapitools/client/JacksonResponseDecoder.java src/main/java/org/openapitools/client/ParamExpander.java src/main/java/org/openapitools/client/RFC3339DateFormat.java src/main/java/org/openapitools/client/ServerConfiguration.java @@ -40,6 +40,7 @@ src/main/java/org/openapitools/client/auth/OauthClientCredentialsGrant.java src/main/java/org/openapitools/client/auth/OauthPasswordGrant.java src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java src/main/java/org/openapitools/client/model/Animal.java +src/main/java/org/openapitools/client/model/ApiResponse.java src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java src/main/java/org/openapitools/client/model/ArrayTest.java @@ -60,7 +61,6 @@ src/main/java/org/openapitools/client/model/Foo.java src/main/java/org/openapitools/client/model/FormatTest.java src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java src/main/java/org/openapitools/client/model/HealthCheckResult.java -src/main/java/org/openapitools/client/model/HttpResponse.java src/main/java/org/openapitools/client/model/InlineResponseDefault.java src/main/java/org/openapitools/client/model/MapTest.java src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java index 006c875c83f..4cb1a3343fa 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiClient.java @@ -23,7 +23,7 @@ import feign.slf4j.Slf4jLogger; import org.openapitools.client.auth.HttpBasicAuth; import org.openapitools.client.auth.HttpBearerAuth; import org.openapitools.client.auth.ApiKeyAuth; -import org.openapitools.client.JacksonResponseDecoder; +import org.openapitools.client.ApiResponseDecoder; import org.openapitools.client.auth.ApiErrorDecoder; import org.openapitools.client.auth.OAuth; @@ -50,7 +50,7 @@ public class ApiClient { feignBuilder = Feign.builder() .client(new OkHttpClient()) .encoder(new FormEncoder(new JacksonEncoder(objectMapper))) - .decoder(new JacksonResponseDecoder(objectMapper)) + .decoder(new ApiResponseDecoder(objectMapper)) .errorDecoder(new ApiErrorDecoder()) .retryer(new Retryer.Default(0, 0, 2)) .logger(new Slf4jLogger()); diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiResponseDecoder.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiResponseDecoder.java new file mode 100644 index 00000000000..d74d1d8768d --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/ApiResponseDecoder.java @@ -0,0 +1,38 @@ +package org.openapitools.client; + +import com.fasterxml.jackson.databind.ObjectMapper; +import feign.Response; +import feign.Types; +import feign.jackson.JacksonDecoder; + +import java.io.IOException; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import org.openapitools.client.model.ApiResponse; + +public class ApiResponseDecoder extends JacksonDecoder { + + public ApiResponseDecoder(ObjectMapper mapper) { + super(mapper); + } + + @Override + public Object decode(Response response, Type type) throws IOException { + Map> responseHeaders = Collections.unmodifiableMap(response.headers()); + //Detects if the type is an instance of the parameterized class ApiResponse + Type responseBodyType; + if (Types.getRawType(type).isAssignableFrom(ApiResponse.class)) { + //The ApiResponse class has a single type parameter, the Dto class itself + responseBodyType = ((ParameterizedType) type).getActualTypeArguments()[0]; + Object body = super.decode(response, responseBodyType); + return new ApiResponse(response.status(), responseHeaders, body); + } else { + //The response is not encapsulated in the ApiResponse, decode the Dto as normal + return super.decode(response, type); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/JacksonResponseDecoder.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/JacksonResponseDecoder.java index 4951d732f22..b3db8c605ab 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/JacksonResponseDecoder.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/JacksonResponseDecoder.java @@ -29,7 +29,7 @@ public class JacksonResponseDecoder extends JacksonDecoder { //The HttpResponse class has a single type parameter, the Dto class itself responseBodyType = ((ParameterizedType) type).getActualTypeArguments()[0]; Object body = super.decode(response, responseBodyType); - return new HttpResponse(responseHeaders, body); + return new HttpResponse(responseHeaders, body, response.status()); } else { //The response is not encapsulated in the HttpResponse, decode the Dto as normal return super.decode(response, type); diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 1585b7dd75c..77d0c2ad878 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.Client; @@ -34,14 +34,14 @@ public interface AnotherFakeApi extends ApiClient.Api { * Similar to call123testSpecialTags but it also returns the http response headers . * To test special tags and operation ID starting with number * @param client client model (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("PATCH /another-fake/dummy") @Headers({ "Content-Type: application/json", "Accept: application/json", }) - HttpResponse call123testSpecialTagsWithHttpInfo(Client client); + ApiResponse call123testSpecialTagsWithHttpInfo(Client client); } diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/DefaultApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/DefaultApi.java index 7621ca7909b..2b69f9144ec 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/DefaultApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/DefaultApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.InlineResponseDefault; @@ -31,13 +31,13 @@ public interface DefaultApi extends ApiClient.Api { * * Similar to fooGet but it also returns the http response headers . * - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /foo") @Headers({ "Accept: application/json", }) - HttpResponse fooGetWithHttpInfo(); + ApiResponse fooGetWithHttpInfo(); } diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java index fad7b590f40..915a61d9584 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import java.math.BigDecimal; import org.openapitools.client.model.Client; @@ -41,13 +41,13 @@ public interface FakeApi extends ApiClient.Api { * Health check endpoint * Similar to fakeHealthGet but it also returns the http response headers . * - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /fake/health") @Headers({ "Accept: application/json", }) - HttpResponse fakeHealthGetWithHttpInfo(); + ApiResponse fakeHealthGetWithHttpInfo(); @@ -80,7 +80,7 @@ public interface FakeApi extends ApiClient.Api { "Accept: application/json", "header_1: {header1}" }) - HttpResponse fakeHttpSignatureTestWithHttpInfo(Pet pet, @Param("query1") String query1, @Param("header1") String header1); + ApiResponse fakeHttpSignatureTestWithHttpInfo(Pet pet, @Param("query1") String query1, @Param("header1") String header1); /** @@ -126,7 +126,7 @@ public interface FakeApi extends ApiClient.Api { "Accept: application/json", "header_1: {header1}" }) - HttpResponse fakeHttpSignatureTestWithHttpInfo(Pet pet, @Param("header1") String header1, @QueryMap(encoded=true) Map queryParams); + ApiResponse fakeHttpSignatureTestWithHttpInfo(Pet pet, @Param("header1") String header1, @QueryMap(encoded=true) Map queryParams); /** @@ -158,14 +158,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterBooleanSerialize but it also returns the http response headers . * Test serialization of outer boolean types * @param body Input boolean as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/boolean") @Headers({ "Content-Type: application/json", "Accept: */*", }) - HttpResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body); + ApiResponse fakeOuterBooleanSerializeWithHttpInfo(Boolean body); @@ -187,14 +187,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterCompositeSerialize but it also returns the http response headers . * Test serialization of object with outer number type * @param outerComposite Input composite as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/composite") @Headers({ "Content-Type: application/json", "Accept: */*", }) - HttpResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite outerComposite); + ApiResponse fakeOuterCompositeSerializeWithHttpInfo(OuterComposite outerComposite); @@ -216,14 +216,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterNumberSerialize but it also returns the http response headers . * Test serialization of outer number types * @param body Input number as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/number") @Headers({ "Content-Type: application/json", "Accept: */*", }) - HttpResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body); + ApiResponse fakeOuterNumberSerializeWithHttpInfo(BigDecimal body); @@ -245,14 +245,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakeOuterStringSerialize but it also returns the http response headers . * Test serialization of outer string types * @param body Input string as post body (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/outer/string") @Headers({ "Content-Type: application/json", "Accept: */*", }) - HttpResponse fakeOuterStringSerializeWithHttpInfo(String body); + ApiResponse fakeOuterStringSerializeWithHttpInfo(String body); @@ -274,14 +274,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to fakePropertyEnumIntegerSerialize but it also returns the http response headers . * Test serialization of enum (int) properties with examples * @param outerObjectWithEnumProperty Input enum (int) as post body (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/property/enum-int") @Headers({ "Content-Type: application/json", "Accept: */*", }) - HttpResponse fakePropertyEnumIntegerSerializeWithHttpInfo(OuterObjectWithEnumProperty outerObjectWithEnumProperty); + ApiResponse fakePropertyEnumIntegerSerializeWithHttpInfo(OuterObjectWithEnumProperty outerObjectWithEnumProperty); @@ -308,7 +308,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: image/png", "Accept: application/json", }) - HttpResponse testBodyWithBinaryWithHttpInfo(File body); + ApiResponse testBodyWithBinaryWithHttpInfo(File body); @@ -335,7 +335,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass); + ApiResponse testBodyWithFileSchemaWithHttpInfo(FileSchemaTestClass fileSchemaTestClass); @@ -364,7 +364,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testBodyWithQueryParamsWithHttpInfo(@Param("query") String query, User user); + ApiResponse testBodyWithQueryParamsWithHttpInfo(@Param("query") String query, User user); /** @@ -406,7 +406,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testBodyWithQueryParamsWithHttpInfo(User user, @QueryMap(encoded=true) Map queryParams); + ApiResponse testBodyWithQueryParamsWithHttpInfo(User user, @QueryMap(encoded=true) Map queryParams); /** @@ -438,14 +438,14 @@ public interface FakeApi extends ApiClient.Api { * Similar to testClientModel but it also returns the http response headers . * To test \"client\" model * @param client client model (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("PATCH /fake") @Headers({ "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testClientModelWithHttpInfo(Client client); + ApiResponse testClientModelWithHttpInfo(Client client); @@ -498,7 +498,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/x-www-form-urlencoded", "Accept: application/json", }) - HttpResponse testEndpointParametersWithHttpInfo(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback); + ApiResponse testEndpointParametersWithHttpInfo(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback); @@ -545,7 +545,7 @@ public interface FakeApi extends ApiClient.Api { "enum_header_string: {enumHeaderString}" }) - HttpResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString); + ApiResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString); /** @@ -605,7 +605,7 @@ public interface FakeApi extends ApiClient.Api { "enum_header_string: {enumHeaderString}" }) - HttpResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString, @QueryMap(encoded=true) Map queryParams); + ApiResponse testEnumParametersWithHttpInfo(@Param("enumHeaderStringArray") List enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumFormStringArray") List enumFormStringArray, @Param("enumFormString") String enumFormString, @QueryMap(encoded=true) Map queryParams); /** @@ -668,7 +668,7 @@ public interface FakeApi extends ApiClient.Api { "boolean_group: {booleanGroup}" }) - HttpResponse testGroupParametersWithHttpInfo(@Param("requiredStringGroup") Integer requiredStringGroup, @Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("requiredInt64Group") Long requiredInt64Group, @Param("stringGroup") Integer stringGroup, @Param("booleanGroup") Boolean booleanGroup, @Param("int64Group") Long int64Group); + ApiResponse testGroupParametersWithHttpInfo(@Param("requiredStringGroup") Integer requiredStringGroup, @Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("requiredInt64Group") Long requiredInt64Group, @Param("stringGroup") Integer stringGroup, @Param("booleanGroup") Boolean booleanGroup, @Param("int64Group") Long int64Group); /** @@ -722,7 +722,7 @@ public interface FakeApi extends ApiClient.Api { "boolean_group: {booleanGroup}" }) - HttpResponse testGroupParametersWithHttpInfo(@Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("booleanGroup") Boolean booleanGroup, @QueryMap(encoded=true) Map queryParams); + ApiResponse testGroupParametersWithHttpInfo(@Param("requiredBooleanGroup") Boolean requiredBooleanGroup, @Param("booleanGroup") Boolean booleanGroup, @QueryMap(encoded=true) Map queryParams); /** @@ -771,7 +771,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testInlineAdditionalPropertiesWithHttpInfo(Map requestBody); + ApiResponse testInlineAdditionalPropertiesWithHttpInfo(Map requestBody); @@ -800,7 +800,7 @@ public interface FakeApi extends ApiClient.Api { "Content-Type: application/x-www-form-urlencoded", "Accept: application/json", }) - HttpResponse testJsonFormDataWithHttpInfo(@Param("param") String param, @Param("param2") String param2); + ApiResponse testJsonFormDataWithHttpInfo(@Param("param") String param, @Param("param2") String param2); @@ -837,7 +837,7 @@ public interface FakeApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse testQueryParameterCollectionFormatWithHttpInfo(@Param("pipe") List pipe, @Param("ioutil") List ioutil, @Param("http") List http, @Param("url") List url, @Param("context") List context, @Param("allowEmpty") String allowEmpty, @Param("language") Map language); + ApiResponse testQueryParameterCollectionFormatWithHttpInfo(@Param("pipe") List pipe, @Param("ioutil") List ioutil, @Param("http") List http, @Param("url") List url, @Param("context") List context, @Param("allowEmpty") String allowEmpty, @Param("language") Map language); /** @@ -887,7 +887,7 @@ public interface FakeApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse testQueryParameterCollectionFormatWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse testQueryParameterCollectionFormatWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 733d9d3ad26..52bc9873d97 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.Client; @@ -34,14 +34,14 @@ public interface FakeClassnameTags123Api extends ApiClient.Api { * Similar to testClassname but it also returns the http response headers . * To test class name in snake case * @param client client model (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("PATCH /fake_classname_test") @Headers({ "Content-Type: application/json", "Accept: application/json", }) - HttpResponse testClassnameWithHttpInfo(Client client); + ApiResponse testClassnameWithHttpInfo(Client client); } diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java index bf38d9e518e..a57cd9481b9 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/PetApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import java.io.File; import org.openapitools.client.model.ModelApiResponse; @@ -42,7 +42,7 @@ public interface PetApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse addPetWithHttpInfo(Pet pet); + ApiResponse addPetWithHttpInfo(Pet pet); @@ -71,7 +71,7 @@ public interface PetApi extends ApiClient.Api { "Accept: application/json", "api_key: {apiKey}" }) - HttpResponse deletePetWithHttpInfo(@Param("petId") Long petId, @Param("apiKey") String apiKey); + ApiResponse deletePetWithHttpInfo(@Param("petId") Long petId, @Param("apiKey") String apiKey); @@ -92,13 +92,13 @@ public interface PetApi extends ApiClient.Api { * Similar to findPetsByStatus but it also returns the http response headers . * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /pet/findByStatus?status={status}") @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByStatusWithHttpInfo(@Param("status") List status); + ApiResponse> findPetsByStatusWithHttpInfo(@Param("status") List status); /** @@ -138,7 +138,7 @@ public interface PetApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByStatusWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse> findPetsByStatusWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** @@ -171,7 +171,7 @@ public interface PetApi extends ApiClient.Api { * Similar to findPetsByTags but it also returns the http response headers . * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. * @deprecated */ @Deprecated @@ -179,7 +179,7 @@ public interface PetApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByTagsWithHttpInfo(@Param("tags") Set tags); + ApiResponse> findPetsByTagsWithHttpInfo(@Param("tags") Set tags); /** @@ -223,7 +223,7 @@ public interface PetApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse> findPetsByTagsWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse> findPetsByTagsWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** @@ -254,13 +254,13 @@ public interface PetApi extends ApiClient.Api { * Similar to getPetById but it also returns the http response headers . * Returns a single pet * @param petId ID of pet to return (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /pet/{petId}") @Headers({ "Accept: application/json", }) - HttpResponse getPetByIdWithHttpInfo(@Param("petId") Long petId); + ApiResponse getPetByIdWithHttpInfo(@Param("petId") Long petId); @@ -287,7 +287,7 @@ public interface PetApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse updatePetWithHttpInfo(Pet pet); + ApiResponse updatePetWithHttpInfo(Pet pet); @@ -318,7 +318,7 @@ public interface PetApi extends ApiClient.Api { "Content-Type: application/x-www-form-urlencoded", "Accept: application/json", }) - HttpResponse updatePetWithFormWithHttpInfo(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status); + ApiResponse updatePetWithFormWithHttpInfo(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status); @@ -344,14 +344,14 @@ public interface PetApi extends ApiClient.Api { * @param petId ID of pet to update (required) * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /pet/{petId}/uploadImage") @Headers({ "Content-Type: multipart/form-data", "Accept: application/json", }) - HttpResponse uploadFileWithHttpInfo(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); + ApiResponse uploadFileWithHttpInfo(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); @@ -377,14 +377,14 @@ public interface PetApi extends ApiClient.Api { * @param petId ID of pet to update (required) * @param requiredFile file to upload (required) * @param additionalMetadata Additional data to pass to server (optional) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /fake/{petId}/uploadImageWithRequiredFile") @Headers({ "Content-Type: multipart/form-data", "Accept: application/json", }) - HttpResponse uploadFileWithRequiredFileWithHttpInfo(@Param("petId") Long petId, @Param("requiredFile") File requiredFile, @Param("additionalMetadata") String additionalMetadata); + ApiResponse uploadFileWithRequiredFileWithHttpInfo(@Param("petId") Long petId, @Param("requiredFile") File requiredFile, @Param("additionalMetadata") String additionalMetadata); } diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/StoreApi.java index 638e6df824c..c5cefaa7a4b 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/StoreApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.Order; @@ -37,7 +37,7 @@ public interface StoreApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse deleteOrderWithHttpInfo(@Param("orderId") String orderId); + ApiResponse deleteOrderWithHttpInfo(@Param("orderId") String orderId); @@ -56,13 +56,13 @@ public interface StoreApi extends ApiClient.Api { * Returns pet inventories by status * Similar to getInventory but it also returns the http response headers . * Returns a map of status codes to quantities - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /store/inventory") @Headers({ "Accept: application/json", }) - HttpResponse> getInventoryWithHttpInfo(); + ApiResponse> getInventoryWithHttpInfo(); @@ -83,13 +83,13 @@ public interface StoreApi extends ApiClient.Api { * Similar to getOrderById but it also returns the http response headers . * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /store/order/{orderId}") @Headers({ "Accept: application/json", }) - HttpResponse getOrderByIdWithHttpInfo(@Param("orderId") Long orderId); + ApiResponse getOrderByIdWithHttpInfo(@Param("orderId") Long orderId); @@ -111,14 +111,14 @@ public interface StoreApi extends ApiClient.Api { * Similar to placeOrder but it also returns the http response headers . * * @param order order placed for purchasing the pet (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("POST /store/order") @Headers({ "Content-Type: application/json", "Accept: application/json", }) - HttpResponse placeOrderWithHttpInfo(Order order); + ApiResponse placeOrderWithHttpInfo(Order order); } diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/UserApi.java index 99e634ab9ac..c6a74a80c00 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/api/UserApi.java @@ -2,7 +2,7 @@ package org.openapitools.client.api; import org.openapitools.client.ApiClient; import org.openapitools.client.EncodingUtils; -import org.openapitools.client.model.HttpResponse; +import org.openapitools.client.model.ApiResponse; import org.openapitools.client.model.User; @@ -39,7 +39,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse createUserWithHttpInfo(User user); + ApiResponse createUserWithHttpInfo(User user); @@ -66,7 +66,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse createUsersWithArrayInputWithHttpInfo(List user); + ApiResponse createUsersWithArrayInputWithHttpInfo(List user); @@ -93,7 +93,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse createUsersWithListInputWithHttpInfo(List user); + ApiResponse createUsersWithListInputWithHttpInfo(List user); @@ -118,7 +118,7 @@ public interface UserApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse deleteUserWithHttpInfo(@Param("username") String username); + ApiResponse deleteUserWithHttpInfo(@Param("username") String username); @@ -139,13 +139,13 @@ public interface UserApi extends ApiClient.Api { * Similar to getUserByName but it also returns the http response headers . * * @param username The name that needs to be fetched. Use user1 for testing. (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /user/{username}") @Headers({ "Accept: application/json", }) - HttpResponse getUserByNameWithHttpInfo(@Param("username") String username); + ApiResponse getUserByNameWithHttpInfo(@Param("username") String username); @@ -168,13 +168,13 @@ public interface UserApi extends ApiClient.Api { * * @param username The user name for login (required) * @param password The password for login in clear text (required) - * @return A HttpResponse that wraps the response boyd and the http headers. + * @return A ApiResponse that wraps the response boyd and the http headers. */ @RequestLine("GET /user/login?username={username}&password={password}") @Headers({ "Accept: application/json", }) - HttpResponse loginUserWithHttpInfo(@Param("username") String username, @Param("password") String password); + ApiResponse loginUserWithHttpInfo(@Param("username") String username, @Param("password") String password); /** @@ -216,7 +216,7 @@ public interface UserApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse loginUserWithHttpInfo(@QueryMap(encoded=true) Map queryParams); + ApiResponse loginUserWithHttpInfo(@QueryMap(encoded=true) Map queryParams); /** @@ -253,7 +253,7 @@ public interface UserApi extends ApiClient.Api { @Headers({ "Accept: application/json", }) - HttpResponse logoutUserWithHttpInfo(); + ApiResponse logoutUserWithHttpInfo(); @@ -282,7 +282,7 @@ public interface UserApi extends ApiClient.Api { "Content-Type: application/json", "Accept: application/json", }) - HttpResponse updateUserWithHttpInfo(@Param("username") String username, User user); + ApiResponse updateUserWithHttpInfo(@Param("username") String username, User user); } diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java index 4ddfc678e92..2a33ff9434a 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/auth/ApiErrorDecoder.java @@ -5,7 +5,7 @@ import feign.RetryableException; import feign.codec.ErrorDecoder; /** - * Error decoder that makes the HTTP 401 and 403 Retryable. Sometimes the 401 or 402 may indicate an expired token + * Error decoder that makes the HTTP 401 and 403 Retryable. Sometimes the 401 or 403 may indicate an expired token * All the other HTTP status are handled by the {@link feign.codec.ErrorDecoder.Default} decoder */ public class ApiErrorDecoder implements ErrorDecoder { diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ApiResponse.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ApiResponse.java new file mode 100644 index 00000000000..a0d44e724c5 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/ApiResponse.java @@ -0,0 +1,43 @@ +package org.openapitools.client.model; + +import java.util.Map; +import java.util.List; + +public class ApiResponse{ + + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/HttpResponse.java b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/HttpResponse.java index d4f45014034..f0e57a0af73 100644 --- a/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/HttpResponse.java +++ b/samples/client/petstore/java/feign/src/main/java/org/openapitools/client/model/HttpResponse.java @@ -9,9 +9,12 @@ public class HttpResponse{ private T body; - public HttpResponse(Map> headers, T body) { + private int status; + + public HttpResponse(Map> headers, T body, int status) { this.headers = headers; this.body = body; + this.status = status; } public T getBody(){ @@ -21,4 +24,8 @@ public class HttpResponse{ public Map> getHeaders(){ return headers; } + + public int getStatus(){ + return status; + } } \ No newline at end of file