forked from loafle/openapi-generator-original
improve enum support in java okhttp-gson client
This commit is contained in:
@@ -7,14 +7,16 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Animal
|
||||
*/
|
||||
public class Animal {
|
||||
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@@ -25,6 +27,7 @@ public class Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -64,3 +67,4 @@ public class Animal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,19 @@ import io.swagger.client.model.Animal;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cat
|
||||
*/
|
||||
public class Cat extends Animal {
|
||||
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
|
||||
@SerializedName("declawed")
|
||||
private Boolean declawed = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@@ -29,6 +31,7 @@ public class Cat extends Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -39,6 +42,7 @@ public class Cat extends Animal {
|
||||
this.declawed = declawed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -81,3 +85,4 @@ public class Cat extends Animal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
public class Category {
|
||||
|
||||
@SerializedName("id")
|
||||
@@ -79,3 +79,4 @@ public class Category {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,19 @@ import io.swagger.client.model.Animal;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Dog
|
||||
*/
|
||||
public class Dog extends Animal {
|
||||
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
|
||||
@SerializedName("breed")
|
||||
private String breed = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@@ -29,6 +31,7 @@ public class Dog extends Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -39,6 +42,7 @@ public class Dog extends Animal {
|
||||
this.breed = breed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -81,3 +85,4 @@ public class Dog extends Animal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
/**
|
||||
* Gets or Sets EnumClass
|
||||
*/
|
||||
public enum EnumClass {
|
||||
@SerializedName("_abc")
|
||||
_ABC("_abc"),
|
||||
|
||||
@SerializedName("-efg")
|
||||
_EFG("-efg"),
|
||||
|
||||
@SerializedName("(xyz)")
|
||||
_XYZ_("(xyz)");
|
||||
|
||||
private String value;
|
||||
|
||||
EnumClass(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
/**
|
||||
* EnumTest
|
||||
*/
|
||||
public class EnumTest {
|
||||
|
||||
|
||||
/**
|
||||
* Gets or Sets enumString
|
||||
*/
|
||||
public enum EnumStringEnum {
|
||||
@SerializedName("UPPER")
|
||||
UPPER("UPPER"),
|
||||
|
||||
@SerializedName("lower")
|
||||
LOWER("lower");
|
||||
|
||||
private String value;
|
||||
|
||||
EnumStringEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("enum_string")
|
||||
private EnumStringEnum enumString = null;
|
||||
|
||||
|
||||
/**
|
||||
* Gets or Sets enumInteger
|
||||
*/
|
||||
public enum EnumIntegerEnum {
|
||||
@SerializedName("1")
|
||||
NUMBER_1(1),
|
||||
|
||||
@SerializedName("-1")
|
||||
NUMBER_MINUS_1(-1);
|
||||
|
||||
private Integer value;
|
||||
|
||||
EnumIntegerEnum(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("enum_integer")
|
||||
private EnumIntegerEnum enumInteger = null;
|
||||
|
||||
|
||||
/**
|
||||
* Gets or Sets enumNumber
|
||||
*/
|
||||
public enum EnumNumberEnum {
|
||||
@SerializedName("1.1")
|
||||
NUMBER_1_DOT_1(1.1),
|
||||
|
||||
@SerializedName("-1.2")
|
||||
NUMBER_MINUS_1_DOT_2(-1.2);
|
||||
|
||||
private Double value;
|
||||
|
||||
EnumNumberEnum(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("enum_number")
|
||||
private EnumNumberEnum enumNumber = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public EnumStringEnum getEnumString() {
|
||||
return enumString;
|
||||
}
|
||||
public void setEnumString(EnumStringEnum enumString) {
|
||||
this.enumString = enumString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public EnumIntegerEnum getEnumInteger() {
|
||||
return enumInteger;
|
||||
}
|
||||
public void setEnumInteger(EnumIntegerEnum enumInteger) {
|
||||
this.enumInteger = enumInteger;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public EnumNumberEnum getEnumNumber() {
|
||||
return enumNumber;
|
||||
}
|
||||
public void setEnumNumber(EnumNumberEnum enumNumber) {
|
||||
this.enumNumber = enumNumber;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
EnumTest enumTest = (EnumTest) o;
|
||||
return Objects.equals(this.enumString, enumTest.enumString) &&
|
||||
Objects.equals(this.enumInteger, enumTest.enumInteger) &&
|
||||
Objects.equals(this.enumNumber, enumTest.enumNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(enumString, enumInteger, enumNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class EnumTest {\n");
|
||||
|
||||
sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n");
|
||||
sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n");
|
||||
sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,17 +7,16 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing model name starting with number
|
||||
**/
|
||||
@ApiModel(description = "Model for testing model name starting with number")
|
||||
* Model200Response
|
||||
*/
|
||||
public class Model200Response {
|
||||
|
||||
@SerializedName("name")
|
||||
private Integer name = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -28,6 +27,7 @@ public class Model200Response {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -67,3 +67,4 @@ public class Model200Response {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,16 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing reserved words
|
||||
**/
|
||||
@ApiModel(description = "Model for testing reserved words")
|
||||
* ModelReturn
|
||||
*/
|
||||
public class ModelReturn {
|
||||
|
||||
@SerializedName("return")
|
||||
private Integer _return = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -28,6 +27,7 @@ public class ModelReturn {
|
||||
this._return = _return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -67,3 +67,4 @@ public class ModelReturn {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,26 +7,22 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing model name same as property name
|
||||
**/
|
||||
@ApiModel(description = "Model for testing model name same as property name")
|
||||
* Name
|
||||
*/
|
||||
public class Name {
|
||||
|
||||
@SerializedName("name")
|
||||
private Integer name = null;
|
||||
|
||||
|
||||
@SerializedName("snake_case")
|
||||
private Integer snakeCase = null;
|
||||
|
||||
|
||||
@SerializedName("property")
|
||||
private String property = null;
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@ApiModelProperty(value = "")
|
||||
public Integer getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -34,23 +30,18 @@ public class Name {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public Integer getSnakeCase() {
|
||||
return snakeCase;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
public void setSnakeCase(Integer snakeCase) {
|
||||
this.snakeCase = snakeCase;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -62,13 +53,12 @@ public class Name {
|
||||
}
|
||||
Name name = (Name) o;
|
||||
return Objects.equals(this.name, name.name) &&
|
||||
Objects.equals(this.snakeCase, name.snakeCase) &&
|
||||
Objects.equals(this.property, name.property);
|
||||
Objects.equals(this.snakeCase, name.snakeCase);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, snakeCase, property);
|
||||
return Objects.hash(name, snakeCase);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,7 +68,6 @@ public class Name {
|
||||
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n");
|
||||
sb.append(" property: ").append(toIndentedString(property)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -94,3 +83,4 @@ public class Name {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,62 +8,65 @@ import java.util.Date;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Order
|
||||
*/
|
||||
public class Order {
|
||||
|
||||
@SerializedName("id")
|
||||
private Long id = null;
|
||||
|
||||
|
||||
@SerializedName("petId")
|
||||
private Long petId = null;
|
||||
|
||||
|
||||
@SerializedName("quantity")
|
||||
private Integer quantity = null;
|
||||
|
||||
|
||||
@SerializedName("shipDate")
|
||||
private Date shipDate = null;
|
||||
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
@SerializedName("placed")
|
||||
PLACED("placed"),
|
||||
|
||||
public enum StatusEnum {
|
||||
@SerializedName("placed")
|
||||
PLACED("placed"),
|
||||
@SerializedName("approved")
|
||||
APPROVED("approved"),
|
||||
|
||||
@SerializedName("approved")
|
||||
APPROVED("approved"),
|
||||
@SerializedName("delivered")
|
||||
DELIVERED("delivered");
|
||||
|
||||
@SerializedName("delivered")
|
||||
DELIVERED("delivered");
|
||||
private String value;
|
||||
|
||||
private String value;
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("status")
|
||||
private StatusEnum status = null;
|
||||
|
||||
private StatusEnum status = StatusEnum.PLACED;
|
||||
|
||||
@SerializedName("complete")
|
||||
private Boolean complete = false;
|
||||
private Boolean complete = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -74,6 +77,7 @@ public enum StatusEnum {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -84,6 +88,7 @@ public enum StatusEnum {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -94,6 +99,7 @@ public enum StatusEnum {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
**/
|
||||
@@ -105,6 +111,7 @@ public enum StatusEnum {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@@ -115,6 +122,7 @@ public enum StatusEnum {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@@ -164,3 +172,4 @@ public enum StatusEnum {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import java.util.List;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pet
|
||||
*/
|
||||
public class Pet {
|
||||
|
||||
@SerializedName("id")
|
||||
@@ -32,28 +32,31 @@ public class Pet {
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
|
||||
|
||||
public enum StatusEnum {
|
||||
@SerializedName("available")
|
||||
AVAILABLE("available"),
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
@SerializedName("available")
|
||||
AVAILABLE("available"),
|
||||
|
||||
@SerializedName("pending")
|
||||
PENDING("pending"),
|
||||
@SerializedName("pending")
|
||||
PENDING("pending"),
|
||||
|
||||
@SerializedName("sold")
|
||||
SOLD("sold");
|
||||
@SerializedName("sold")
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("status")
|
||||
private StatusEnum status = null;
|
||||
|
||||
@@ -167,3 +170,4 @@ public enum StatusEnum {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* SpecialModelName
|
||||
*/
|
||||
public class SpecialModelName {
|
||||
|
||||
@SerializedName("$special[property.name]")
|
||||
@@ -64,3 +64,4 @@ public class SpecialModelName {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tag
|
||||
*/
|
||||
public class Tag {
|
||||
|
||||
@SerializedName("id")
|
||||
@@ -79,3 +79,4 @@ public class Tag {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
public class User {
|
||||
|
||||
@SerializedName("id")
|
||||
@@ -170,3 +170,4 @@ public class User {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user