mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 03:22:42 +00:00
[Java][Spring][Inflector][Jax-RS] To fix various enum issues (#3615)
* fix spring enum deserialization issue * fix enum class for spring * update java inflector to fix enum tostring * fix jaxrs jersey1 enum toString * fix jaxrs jersey patch issue
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Client;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.swagger.api;
|
||||
|
||||
import io.swagger.model.Pet;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
import java.io.File;
|
||||
import io.swagger.model.ModelApiResponse;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -17,8 +17,10 @@ import java.util.Map;
|
||||
*/
|
||||
|
||||
public class AdditionalPropertiesClass {
|
||||
@JsonProperty("map_property")
|
||||
private Map<String, String> mapProperty = new HashMap<String, String>();
|
||||
|
||||
@JsonProperty("map_of_map_property")
|
||||
private Map<String, Map<String, String>> mapOfMapProperty = new HashMap<String, Map<String, String>>();
|
||||
|
||||
public AdditionalPropertiesClass mapProperty(Map<String, String> mapProperty) {
|
||||
|
||||
@@ -14,8 +14,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class Animal {
|
||||
@JsonProperty("className")
|
||||
private String className = null;
|
||||
|
||||
@JsonProperty("color")
|
||||
private String color = "red";
|
||||
|
||||
public Animal className(String className) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public class ArrayOfArrayOfNumberOnly {
|
||||
@JsonProperty("ArrayArrayNumber")
|
||||
private List<List<BigDecimal>> arrayArrayNumber = new ArrayList<List<BigDecimal>>();
|
||||
|
||||
public ArrayOfArrayOfNumberOnly arrayArrayNumber(List<List<BigDecimal>> arrayArrayNumber) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public class ArrayOfNumberOnly {
|
||||
@JsonProperty("ArrayNumber")
|
||||
private List<BigDecimal> arrayNumber = new ArrayList<BigDecimal>();
|
||||
|
||||
public ArrayOfNumberOnly arrayNumber(List<BigDecimal> arrayNumber) {
|
||||
|
||||
@@ -17,10 +17,13 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public class ArrayTest {
|
||||
@JsonProperty("array_of_string")
|
||||
private List<String> arrayOfString = new ArrayList<String>();
|
||||
|
||||
@JsonProperty("array_array_of_integer")
|
||||
private List<List<Long>> arrayArrayOfInteger = new ArrayList<List<Long>>();
|
||||
|
||||
@JsonProperty("array_array_of_model")
|
||||
private List<List<ReadOnlyFirst>> arrayArrayOfModel = new ArrayList<List<ReadOnlyFirst>>();
|
||||
|
||||
public ArrayTest arrayOfString(List<String> arrayOfString) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.swagger.model.Animal;
|
||||
*/
|
||||
|
||||
public class Cat extends Animal {
|
||||
@JsonProperty("declawed")
|
||||
private Boolean declawed = null;
|
||||
|
||||
public Cat declawed(Boolean declawed) {
|
||||
|
||||
@@ -14,8 +14,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class Category {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
public Category id(Long id) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class Client {
|
||||
@JsonProperty("client")
|
||||
private String client = null;
|
||||
|
||||
public Client client(String client) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import io.swagger.model.Animal;
|
||||
*/
|
||||
|
||||
public class Dog extends Animal {
|
||||
@JsonProperty("breed")
|
||||
private String breed = null;
|
||||
|
||||
public Dog breed(String breed) {
|
||||
|
||||
@@ -32,11 +32,23 @@ public class EnumArrays {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static JustSymbolEnum fromValue(String text) {
|
||||
for (JustSymbolEnum b : JustSymbolEnum.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("just_symbol")
|
||||
private JustSymbolEnum justSymbol = null;
|
||||
|
||||
/**
|
||||
@@ -54,11 +66,23 @@ public class EnumArrays {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static ArrayEnumEnum fromValue(String text) {
|
||||
for (ArrayEnumEnum b : ArrayEnumEnum.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("array_enum")
|
||||
private List<ArrayEnumEnum> arrayEnum = new ArrayList<ArrayEnumEnum>();
|
||||
|
||||
public EnumArrays justSymbol(JustSymbolEnum justSymbol) {
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
* Gets or Sets EnumClass
|
||||
*/
|
||||
@@ -23,9 +25,20 @@ public enum EnumClass {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,11 +30,23 @@ public class EnumTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
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")
|
||||
private EnumStringEnum enumString = null;
|
||||
|
||||
/**
|
||||
@@ -52,11 +64,23 @@ public class EnumTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
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")
|
||||
private EnumIntegerEnum enumInteger = null;
|
||||
|
||||
/**
|
||||
@@ -74,11 +98,23 @@ public class EnumTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
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")
|
||||
private EnumNumberEnum enumNumber = null;
|
||||
|
||||
public EnumTest enumString(EnumStringEnum enumString) {
|
||||
|
||||
@@ -17,30 +17,43 @@ import java.time.OffsetDateTime;
|
||||
*/
|
||||
|
||||
public class FormatTest {
|
||||
@JsonProperty("integer")
|
||||
private Integer integer = null;
|
||||
|
||||
@JsonProperty("int32")
|
||||
private Integer int32 = null;
|
||||
|
||||
@JsonProperty("int64")
|
||||
private Long int64 = null;
|
||||
|
||||
@JsonProperty("number")
|
||||
private BigDecimal number = null;
|
||||
|
||||
@JsonProperty("float")
|
||||
private Float _float = null;
|
||||
|
||||
@JsonProperty("double")
|
||||
private Double _double = null;
|
||||
|
||||
@JsonProperty("string")
|
||||
private String string = null;
|
||||
|
||||
@JsonProperty("byte")
|
||||
private byte[] _byte = null;
|
||||
|
||||
@JsonProperty("binary")
|
||||
private byte[] binary = null;
|
||||
|
||||
@JsonProperty("date")
|
||||
private LocalDate date = null;
|
||||
|
||||
@JsonProperty("dateTime")
|
||||
private OffsetDateTime dateTime = null;
|
||||
|
||||
@JsonProperty("uuid")
|
||||
private String uuid = null;
|
||||
|
||||
@JsonProperty("password")
|
||||
private String password = null;
|
||||
|
||||
public FormatTest integer(Integer integer) {
|
||||
|
||||
@@ -14,8 +14,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class HasOnlyReadOnly {
|
||||
@JsonProperty("bar")
|
||||
private String bar = null;
|
||||
|
||||
@JsonProperty("foo")
|
||||
private String foo = null;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Map;
|
||||
*/
|
||||
|
||||
public class MapTest {
|
||||
@JsonProperty("map_map_of_string")
|
||||
private Map<String, Map<String, String>> mapMapOfString = new HashMap<String, Map<String, String>>();
|
||||
|
||||
/**
|
||||
@@ -35,11 +36,23 @@ public class MapTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
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")
|
||||
private Map<String, InnerEnum> mapOfEnumString = new HashMap<String, InnerEnum>();
|
||||
|
||||
public MapTest mapMapOfString(Map<String, Map<String, String>> mapMapOfString) {
|
||||
|
||||
@@ -19,10 +19,13 @@ import java.util.Map;
|
||||
*/
|
||||
|
||||
public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
@JsonProperty("uuid")
|
||||
private String uuid = null;
|
||||
|
||||
@JsonProperty("dateTime")
|
||||
private OffsetDateTime dateTime = null;
|
||||
|
||||
@JsonProperty("map")
|
||||
private Map<String, Animal> map = new HashMap<String, Animal>();
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass uuid(String uuid) {
|
||||
|
||||
@@ -18,8 +18,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
@ApiModel(description = "Model for testing model name starting with number")
|
||||
|
||||
public class Model200Response {
|
||||
@JsonProperty("name")
|
||||
private Integer name = null;
|
||||
|
||||
@JsonProperty("class")
|
||||
private String PropertyClass = null;
|
||||
|
||||
public Model200Response name(Integer name) {
|
||||
|
||||
@@ -14,10 +14,13 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class ModelApiResponse {
|
||||
@JsonProperty("code")
|
||||
private Integer code = null;
|
||||
|
||||
@JsonProperty("type")
|
||||
private String type = null;
|
||||
|
||||
@JsonProperty("message")
|
||||
private String message = null;
|
||||
|
||||
public ModelApiResponse code(Integer code) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
@ApiModel(description = "Model for testing reserved words")
|
||||
|
||||
public class ModelReturn {
|
||||
@JsonProperty("return")
|
||||
private Integer _return = null;
|
||||
|
||||
public ModelReturn _return(Integer _return) {
|
||||
|
||||
@@ -18,12 +18,16 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
@ApiModel(description = "Model for testing model name same as property name")
|
||||
|
||||
public class Name {
|
||||
@JsonProperty("name")
|
||||
private Integer name = null;
|
||||
|
||||
@JsonProperty("snake_case")
|
||||
private Integer snakeCase = null;
|
||||
|
||||
@JsonProperty("property")
|
||||
private String property = null;
|
||||
|
||||
@JsonProperty("123Number")
|
||||
private Integer _123Number = null;
|
||||
|
||||
public Name name(Integer name) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.math.BigDecimal;
|
||||
*/
|
||||
|
||||
public class NumberOnly {
|
||||
@JsonProperty("JustNumber")
|
||||
private BigDecimal justNumber = null;
|
||||
|
||||
public NumberOnly justNumber(BigDecimal justNumber) {
|
||||
|
||||
@@ -16,12 +16,16 @@ import java.time.OffsetDateTime;
|
||||
*/
|
||||
|
||||
public class Order {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("petId")
|
||||
private Long petId = null;
|
||||
|
||||
@JsonProperty("quantity")
|
||||
private Integer quantity = null;
|
||||
|
||||
@JsonProperty("shipDate")
|
||||
private OffsetDateTime shipDate = null;
|
||||
|
||||
/**
|
||||
@@ -41,13 +45,26 @@ public class Order {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
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")
|
||||
private StatusEnum status = null;
|
||||
|
||||
@JsonProperty("complete")
|
||||
private Boolean complete = false;
|
||||
|
||||
public Order id(Long id) {
|
||||
|
||||
@@ -19,14 +19,19 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public class Pet {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("category")
|
||||
private Category category = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("photoUrls")
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
|
||||
@JsonProperty("tags")
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
|
||||
/**
|
||||
@@ -46,11 +51,23 @@ public class Pet {
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
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")
|
||||
private StatusEnum status = null;
|
||||
|
||||
public Pet id(Long id) {
|
||||
|
||||
@@ -14,8 +14,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class ReadOnlyFirst {
|
||||
@JsonProperty("bar")
|
||||
private String bar = null;
|
||||
|
||||
@JsonProperty("baz")
|
||||
private String baz = null;
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class SpecialModelName {
|
||||
@JsonProperty("$special[property.name]")
|
||||
private Long specialPropertyName = null;
|
||||
|
||||
public SpecialModelName specialPropertyName(Long specialPropertyName) {
|
||||
|
||||
@@ -14,8 +14,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class Tag {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name = null;
|
||||
|
||||
public Tag id(Long id) {
|
||||
|
||||
@@ -14,20 +14,28 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
|
||||
public class User {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
|
||||
@JsonProperty("username")
|
||||
private String username = null;
|
||||
|
||||
@JsonProperty("firstName")
|
||||
private String firstName = null;
|
||||
|
||||
@JsonProperty("lastName")
|
||||
private String lastName = null;
|
||||
|
||||
@JsonProperty("email")
|
||||
private String email = null;
|
||||
|
||||
@JsonProperty("password")
|
||||
private String password = null;
|
||||
|
||||
@JsonProperty("phone")
|
||||
private String phone = null;
|
||||
|
||||
@JsonProperty("userStatus")
|
||||
private Integer userStatus = null;
|
||||
|
||||
public User id(Long id) {
|
||||
|
||||
Reference in New Issue
Block a user