From d8cdcbf042b730e57ac84fa04f5c6e78c6169fe2 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 8 Aug 2016 00:16:12 +0800 Subject: [PATCH] fix jsoncreator annotation issue with java api clients using gson --- .../main/resources/Java/modelEnum.mustache | 3 +- .../resources/Java/modelInnerEnum.mustache | 2 ++ .../java/io/swagger/client/ApiClient.java | 6 ++-- .../java/io/swagger/client/api/FakeApi.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 4 +-- .../model/AdditionalPropertiesClass.java | 1 + .../java/io/swagger/client/model/Animal.java | 1 + .../model/ArrayOfArrayOfNumberOnly.java | 1 + .../client/model/ArrayOfNumberOnly.java | 1 + .../io/swagger/client/model/ArrayTest.java | 1 + .../java/io/swagger/client/model/Cat.java | 1 + .../io/swagger/client/model/Category.java | 1 + .../java/io/swagger/client/model/Client.java | 1 + .../java/io/swagger/client/model/Dog.java | 1 + .../io/swagger/client/model/EnumClass.java | 12 +++++++ .../io/swagger/client/model/EnumTest.java | 31 +++++++++++++++++++ .../io/swagger/client/model/FormatTest.java | 1 + .../swagger/client/model/HasOnlyReadOnly.java | 1 + .../java/io/swagger/client/model/MapTest.java | 11 +++++++ ...ropertiesAndAdditionalPropertiesClass.java | 1 + .../client/model/Model200Response.java | 1 + .../client/model/ModelApiResponse.java | 1 + .../io/swagger/client/model/ModelReturn.java | 1 + .../java/io/swagger/client/model/Name.java | 1 + .../io/swagger/client/model/NumberOnly.java | 1 + .../java/io/swagger/client/model/Order.java | 11 +++++++ .../java/io/swagger/client/model/Pet.java | 11 +++++++ .../swagger/client/model/ReadOnlyFirst.java | 1 + .../client/model/SpecialModelName.java | 1 + .../java/io/swagger/client/model/Tag.java | 1 + .../java/io/swagger/client/model/User.java | 1 + .../io/swagger/client/model/EnumClass.java | 1 - .../java/jersey2-java8/docs/MapTest.md | 2 ++ .../java/jersey2-java8/docs/PetApi.md | 2 +- .../java/io/swagger/client/ApiClient.java | 2 +- .../java/io/swagger/client/api/FakeApi.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../model/AdditionalPropertiesClass.java | 1 + .../java/io/swagger/client/model/Animal.java | 1 + .../model/ArrayOfArrayOfNumberOnly.java | 1 + .../client/model/ArrayOfNumberOnly.java | 1 + .../io/swagger/client/model/ArrayTest.java | 1 + .../java/io/swagger/client/model/Cat.java | 1 + .../io/swagger/client/model/Category.java | 1 + .../java/io/swagger/client/model/Client.java | 1 + .../java/io/swagger/client/model/Dog.java | 1 + .../io/swagger/client/model/EnumClass.java | 12 +++++++ .../io/swagger/client/model/EnumTest.java | 31 +++++++++++++++++++ .../io/swagger/client/model/FormatTest.java | 1 + .../swagger/client/model/HasOnlyReadOnly.java | 1 + .../java/io/swagger/client/model/MapTest.java | 11 +++++++ ...ropertiesAndAdditionalPropertiesClass.java | 1 + .../client/model/Model200Response.java | 1 + .../client/model/ModelApiResponse.java | 1 + .../io/swagger/client/model/ModelReturn.java | 1 + .../java/io/swagger/client/model/Name.java | 1 + .../io/swagger/client/model/NumberOnly.java | 1 + .../java/io/swagger/client/model/Order.java | 11 +++++++ .../java/io/swagger/client/model/Pet.java | 11 +++++++ .../swagger/client/model/ReadOnlyFirst.java | 1 + .../client/model/SpecialModelName.java | 1 + .../java/io/swagger/client/model/Tag.java | 1 + .../java/io/swagger/client/model/User.java | 1 + .../io/swagger/client/model/EnumClass.java | 1 - .../io/swagger/client/model/EnumClass.java | 1 + .../java/io/swagger/client/ApiClient.java | 6 ++-- .../java/io/swagger/client/api/FakeApi.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../io/swagger/client/model/EnumClass.java | 1 + .../petstore/java/retrofit2/docs/MapTest.md | 2 ++ .../petstore/java/retrofit2/docs/PetApi.md | 2 +- .../java/io/swagger/client/ApiClient.java | 6 ++-- .../java/io/swagger/client/api/FakeApi.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../io/swagger/client/model/EnumClass.java | 1 + .../petstore/java/retrofit2rx/docs/MapTest.md | 2 ++ .../petstore/java/retrofit2rx/docs/PetApi.md | 2 +- .../java/io/swagger/client/ApiClient.java | 6 ++-- .../java/io/swagger/client/api/FakeApi.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../io/swagger/client/model/EnumClass.java | 1 + 81 files changed, 235 insertions(+), 30 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/modelEnum.mustache b/modules/swagger-codegen/src/main/resources/Java/modelEnum.mustache index b8e0d4ebf5b..54198919575 100644 --- a/modules/swagger-codegen/src/main/resources/Java/modelEnum.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/modelEnum.mustache @@ -28,6 +28,7 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum public String toString() { return String.valueOf(value); } +{{#jackson}} @JsonCreator public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { @@ -38,5 +39,5 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum } return null; } - +{{/jackson}} } diff --git a/modules/swagger-codegen/src/main/resources/Java/modelInnerEnum.mustache b/modules/swagger-codegen/src/main/resources/Java/modelInnerEnum.mustache index 50a3ae0639f..f8a7bd2a2da 100644 --- a/modules/swagger-codegen/src/main/resources/Java/modelInnerEnum.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/modelInnerEnum.mustache @@ -30,6 +30,7 @@ public String toString() { return String.valueOf(value); } +{{#jackson}} @JsonCreator public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) { @@ -40,4 +41,5 @@ } return null; } +{{/jackson}} } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java index 75b3a96f2c7..e21bded5212 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java @@ -41,10 +41,10 @@ public ApiClient(String[] authNames) { this(); for(String authName : authNames) { RequestInterceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java index 5825fbfed42..57fa0cdd95a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/FakeApi.java @@ -4,8 +4,8 @@ import io.swagger.client.model.Client; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index e486495c5a9..555203d8811 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -3,8 +3,8 @@ import io.swagger.client.ApiClient; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; @@ -40,7 +40,7 @@ public interface PetApi extends ApiClient.Api { @Headers({ "Content-type: application/json", "Accept: application/json", - "apiKey: {apiKey}" + "api_key: {apiKey}" }) void deletePet(@Param("petId") Long petId, @Param("apiKey") String apiKey); diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java index 8f4540613cf..699b351594c 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.HashMap; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java index 3ed2c6d9660..45f312394b9 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Animal.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java index 7dfc2cf1c64..80d588dd41c 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java index d99dfdac794..eb02c1adee0 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayTest.java index 9e7308f6a8c..1234e946d12 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ArrayTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.ReadOnlyFirst; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java index 753aac88213..a78d6e92515 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Cat.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Animal; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index c9bbbf525c5..45ceb1a1f17 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Client.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Client.java index 2fbd695b1df..46831a0baf6 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Client.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Client.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java index 178ec87c893..83885a79439 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Dog.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Animal; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumClass.java index 4433dca5f48..4d5976527b3 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumClass.java @@ -28,6 +28,8 @@ import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; + /** * Gets or Sets EnumClass */ @@ -49,5 +51,15 @@ public enum EnumClass { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumClass fromValue(String text) { + for (EnumClass b : EnumClass.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumTest.java index de36ef40ed4..e1afab6f1d9 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/EnumTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -54,6 +55,16 @@ public enum EnumStringEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumStringEnum fromValue(String text) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("enum_string") @@ -77,6 +88,16 @@ public enum EnumIntegerEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumIntegerEnum fromValue(String text) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("enum_integer") @@ -100,6 +121,16 @@ public enum EnumNumberEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumNumberEnum fromValue(String text) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("enum_number") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java index 9e17949ebc8..e1822b29ea1 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/FormatTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java index a3d01218197..e1fa6b49b0a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MapTest.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MapTest.java index 0a06e712779..fba119b6cdf 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MapTest.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MapTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.HashMap; @@ -60,6 +61,16 @@ public enum InnerEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static InnerEnum fromValue(String text) { + for (InnerEnum b : InnerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("map_of_enum_string") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 2138c72b648..a6653e1b41e 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Animal; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java index 3f4edf12daa..d617f1d9069 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Model200Response.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java index 7b86d07a148..65b2ad8ddc6 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java index e8762f850db..15193d8d3ba 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ModelReturn.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java index de446cdf30d..d3a4044150e 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Name.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/NumberOnly.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/NumberOnly.java index 88c33f00f02..147e5e00ca3 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/NumberOnly.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/NumberOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index ddebd7f8e48..92b2c156ebc 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.joda.time.DateTime; @@ -69,6 +70,16 @@ public enum StatusEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("status") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index f69ca6ad4b1..d51851f160f 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Category; @@ -75,6 +76,16 @@ public enum StatusEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("status") diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ReadOnlyFirst.java index 7f56ef2ff35..aa4c0b5daa0 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ReadOnlyFirst.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/ReadOnlyFirst.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java index bc4863f101a..4f0d8cc6083 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index f27e45ea2aa..7f28005570a 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index 7c0421fa09e..09dd7156087 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/EnumClass.java index c251caeb86a..4d5976527b3 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/EnumClass.java @@ -61,6 +61,5 @@ public static EnumClass fromValue(String text) { } return null; } - } diff --git a/samples/client/petstore/java/jersey2-java8/docs/MapTest.md b/samples/client/petstore/java/jersey2-java8/docs/MapTest.md index c671e97ffbc..714a97a40d9 100644 --- a/samples/client/petstore/java/jersey2-java8/docs/MapTest.md +++ b/samples/client/petstore/java/jersey2-java8/docs/MapTest.md @@ -12,6 +12,8 @@ Name | Type | Description | Notes ## Enum: Map<String, InnerEnum> Name | Value ---- | ----- +UPPER | "UPPER" +LOWER | "lower" diff --git a/samples/client/petstore/java/jersey2-java8/docs/PetApi.md b/samples/client/petstore/java/jersey2-java8/docs/PetApi.md index e0314e20e51..3b5f84043e3 100644 --- a/samples/client/petstore/java/jersey2-java8/docs/PetApi.md +++ b/samples/client/petstore/java/jersey2-java8/docs/PetApi.md @@ -158,7 +158,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] ### Return type diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java index 617049afbcd..35ee3db9b32 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java @@ -84,8 +84,8 @@ public ApiClient() { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); - authentications.put("petstore_auth", new OAuth()); authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("petstore_auth", new OAuth()); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java index feabca0a7cd..c010d34a655 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/FakeApi.java @@ -8,8 +8,8 @@ import javax.ws.rs.core.GenericType; import io.swagger.client.model.Client; -import java.time.OffsetDateTime; import java.time.LocalDate; +import java.time.OffsetDateTime; import java.math.BigDecimal; import java.util.ArrayList; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java index ad66598406d..ab85c4ac394 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/api/PetApi.java @@ -8,8 +8,8 @@ import javax.ws.rs.core.GenericType; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java index 8f4540613cf..699b351594c 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.HashMap; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Animal.java index 3ed2c6d9660..45f312394b9 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Animal.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Animal.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java index 7dfc2cf1c64..80d588dd41c 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfArrayOfNumberOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java index d99dfdac794..eb02c1adee0 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayOfNumberOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java index 9e7308f6a8c..1234e946d12 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ArrayTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.ReadOnlyFirst; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Cat.java index 753aac88213..a78d6e92515 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Cat.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Cat.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Animal; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Category.java index c9bbbf525c5..45ceb1a1f17 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Category.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Client.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Client.java index 2fbd695b1df..46831a0baf6 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Client.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Client.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Dog.java index 178ec87c893..83885a79439 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Dog.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Dog.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Animal; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumClass.java index 4433dca5f48..4d5976527b3 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumClass.java @@ -28,6 +28,8 @@ import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonCreator; + /** * Gets or Sets EnumClass */ @@ -49,5 +51,15 @@ public enum EnumClass { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumClass fromValue(String text) { + for (EnumClass b : EnumClass.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumTest.java index de36ef40ed4..e1afab6f1d9 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/EnumTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -54,6 +55,16 @@ public enum EnumStringEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumStringEnum fromValue(String text) { + for (EnumStringEnum b : EnumStringEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("enum_string") @@ -77,6 +88,16 @@ public enum EnumIntegerEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumIntegerEnum fromValue(String text) { + for (EnumIntegerEnum b : EnumIntegerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("enum_integer") @@ -100,6 +121,16 @@ public enum EnumNumberEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static EnumNumberEnum fromValue(String text) { + for (EnumNumberEnum b : EnumNumberEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("enum_number") diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/FormatTest.java index 4b49129ea84..92daed84f5f 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/FormatTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/FormatTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java index a3d01218197..e1fa6b49b0a 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/HasOnlyReadOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java index 0a06e712779..fba119b6cdf 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MapTest.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.util.HashMap; @@ -60,6 +61,16 @@ public enum InnerEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static InnerEnum fromValue(String text) { + for (InnerEnum b : InnerEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("map_of_enum_string") diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java index 9881b898258..90878808b8e 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Animal; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Model200Response.java index 3f4edf12daa..d617f1d9069 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Model200Response.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Model200Response.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelApiResponse.java index 7b86d07a148..65b2ad8ddc6 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelApiResponse.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelApiResponse.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelReturn.java index e8762f850db..15193d8d3ba 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelReturn.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ModelReturn.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Name.java index de446cdf30d..d3a4044150e 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Name.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Name.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/NumberOnly.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/NumberOnly.java index 88c33f00f02..147e5e00ca3 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/NumberOnly.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/NumberOnly.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Order.java index 1e7fc88dc38..29230158a9f 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Order.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.time.OffsetDateTime; @@ -69,6 +70,16 @@ public enum StatusEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("status") diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java index f69ca6ad4b1..d51851f160f 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Pet.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.client.model.Category; @@ -75,6 +76,16 @@ public enum StatusEnum { public String toString() { return String.valueOf(value); } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } } @JsonProperty("status") diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ReadOnlyFirst.java index 7f56ef2ff35..aa4c0b5daa0 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ReadOnlyFirst.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/ReadOnlyFirst.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/SpecialModelName.java index bc4863f101a..4f0d8cc6083 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/SpecialModelName.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/SpecialModelName.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Tag.java index f27e45ea2aa..7f28005570a 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/Tag.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/User.java index 7c0421fa09e..09dd7156087 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/User.java @@ -27,6 +27,7 @@ import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumClass.java index c251caeb86a..4d5976527b3 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumClass.java @@ -61,6 +61,5 @@ public static EnumClass fromValue(String text) { } return null; } - } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/EnumClass.java index 73484907229..b53ad4fa8f6 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/EnumClass.java @@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName; + /** * Gets or Sets EnumClass */ diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java index 2363bf4c84f..08cfb4b3751 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/ApiClient.java @@ -54,10 +54,10 @@ public ApiClient(String[] authNames) { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java index 0f1ce0f98ae..076b9fc2ab1 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/FakeApi.java @@ -8,8 +8,8 @@ import io.swagger.client.model.Client; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index a019a4bf886..66ed6aea981 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -7,8 +7,8 @@ import retrofit.mime.*; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/EnumClass.java index 73484907229..b53ad4fa8f6 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/EnumClass.java @@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName; + /** * Gets or Sets EnumClass */ diff --git a/samples/client/petstore/java/retrofit2/docs/MapTest.md b/samples/client/petstore/java/retrofit2/docs/MapTest.md index c671e97ffbc..714a97a40d9 100644 --- a/samples/client/petstore/java/retrofit2/docs/MapTest.md +++ b/samples/client/petstore/java/retrofit2/docs/MapTest.md @@ -12,6 +12,8 @@ Name | Type | Description | Notes ## Enum: Map<String, InnerEnum> Name | Value ---- | ----- +UPPER | "UPPER" +LOWER | "lower" diff --git a/samples/client/petstore/java/retrofit2/docs/PetApi.md b/samples/client/petstore/java/retrofit2/docs/PetApi.md index 40ea199b153..211f5be5fa8 100644 --- a/samples/client/petstore/java/retrofit2/docs/PetApi.md +++ b/samples/client/petstore/java/retrofit2/docs/PetApi.md @@ -160,7 +160,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] ### Return type diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java index 18fa73633f0..604861f6072 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/ApiClient.java @@ -53,10 +53,10 @@ public ApiClient(String[] authNames) { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java index 7d1543fbe4b..9bd1f7b9882 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/FakeApi.java @@ -10,8 +10,8 @@ import io.swagger.client.model.Client; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index a1ea00e368a..a55cb2ee17f 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/EnumClass.java index 73484907229..b53ad4fa8f6 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/EnumClass.java @@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName; + /** * Gets or Sets EnumClass */ diff --git a/samples/client/petstore/java/retrofit2rx/docs/MapTest.md b/samples/client/petstore/java/retrofit2rx/docs/MapTest.md index c671e97ffbc..714a97a40d9 100644 --- a/samples/client/petstore/java/retrofit2rx/docs/MapTest.md +++ b/samples/client/petstore/java/retrofit2rx/docs/MapTest.md @@ -12,6 +12,8 @@ Name | Type | Description | Notes ## Enum: Map<String, InnerEnum> Name | Value ---- | ----- +UPPER | "UPPER" +LOWER | "lower" diff --git a/samples/client/petstore/java/retrofit2rx/docs/PetApi.md b/samples/client/petstore/java/retrofit2rx/docs/PetApi.md index 40ea199b153..211f5be5fa8 100644 --- a/samples/client/petstore/java/retrofit2rx/docs/PetApi.md +++ b/samples/client/petstore/java/retrofit2rx/docs/PetApi.md @@ -160,7 +160,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | [enum: available, pending, sold] ### Return type diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java index 997bbe1401e..43eaeba87f4 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/ApiClient.java @@ -53,10 +53,10 @@ public ApiClient(String[] authNames) { this(); for(String authName : authNames) { Interceptor auth; - if (authName == "petstore_auth") { - auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); - } else if (authName == "api_key") { + if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "petstore_auth") { + auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java index 8dd4da0e72c..aadcdfdee76 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/FakeApi.java @@ -10,8 +10,8 @@ import io.swagger.client.model.Client; import org.joda.time.LocalDate; -import java.math.BigDecimal; import org.joda.time.DateTime; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java index 836de6f11fa..94e2161d5a4 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/api/PetApi.java @@ -9,8 +9,8 @@ import okhttp3.RequestBody; import io.swagger.client.model.Pet; -import io.swagger.client.model.ModelApiResponse; import java.io.File; +import io.swagger.client.model.ModelApiResponse; import java.util.ArrayList; import java.util.HashMap; diff --git a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/EnumClass.java b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/EnumClass.java index 73484907229..b53ad4fa8f6 100644 --- a/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/EnumClass.java +++ b/samples/client/petstore/java/retrofit2rx/src/main/java/io/swagger/client/model/EnumClass.java @@ -29,6 +29,7 @@ import com.google.gson.annotations.SerializedName; + /** * Gets or Sets EnumClass */