forked from loafle/openapi-generator-original
Support models with multi-level hierarchy (via roxspring) (#4503)
* Example of broken multi-level hierarchy * Support for multiple levels of hierarchy in model objects * Support for multiple levels of hierarchy in generators * Regenerated samples * Temporarily skip scalaz sample verification, which is having issue with Java version in CI container * Re-enable scalaz in verify samples Co-authored-by: Rob Oxspring <roxspring@imapmail.org>
This commit is contained in:
committed by
William Cheng
parent
daec02b8c5
commit
376e419d0b
@@ -19,6 +19,7 @@ import javax.validation.constraints.*;
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = Dog.class, name = "Dog"),
|
||||
@JsonSubTypes.Type(value = Cat.class, name = "Cat"),
|
||||
@JsonSubTypes.Type(value = BigCat.class, name = "BigCat"),
|
||||
})
|
||||
|
||||
public class Animal {
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.model.BigCatAllOf;
|
||||
import org.openapitools.model.Cat;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* BigCat
|
||||
*/
|
||||
|
||||
public class BigCat extends Cat {
|
||||
/**
|
||||
* Gets or Sets kind
|
||||
*/
|
||||
public enum KindEnum {
|
||||
LIONS("lions"),
|
||||
|
||||
TIGERS("tigers"),
|
||||
|
||||
LEOPARDS("leopards"),
|
||||
|
||||
JAGUARS("jaguars");
|
||||
|
||||
private String value;
|
||||
|
||||
KindEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static KindEnum fromValue(String value) {
|
||||
for (KindEnum b : KindEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("kind")
|
||||
private KindEnum kind;
|
||||
|
||||
public BigCat kind(KindEnum kind) {
|
||||
this.kind = kind;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get kind
|
||||
* @return kind
|
||||
*/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
|
||||
public KindEnum getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public void setKind(KindEnum kind) {
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BigCat bigCat = (BigCat) o;
|
||||
return Objects.equals(this.kind, bigCat.kind) &&
|
||||
super.equals(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(kind, super.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class BigCat {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" kind: ").append(toIndentedString(kind)).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(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* BigCatAllOf
|
||||
*/
|
||||
|
||||
public class BigCatAllOf {
|
||||
/**
|
||||
* Gets or Sets kind
|
||||
*/
|
||||
public enum KindEnum {
|
||||
LIONS("lions"),
|
||||
|
||||
TIGERS("tigers"),
|
||||
|
||||
LEOPARDS("leopards"),
|
||||
|
||||
JAGUARS("jaguars");
|
||||
|
||||
private String value;
|
||||
|
||||
KindEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonValue
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static KindEnum fromValue(String value) {
|
||||
for (KindEnum b : KindEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("kind")
|
||||
private KindEnum kind;
|
||||
|
||||
public BigCatAllOf kind(KindEnum kind) {
|
||||
this.kind = kind;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get kind
|
||||
* @return kind
|
||||
*/
|
||||
@ApiModelProperty(value = "")
|
||||
|
||||
|
||||
public KindEnum getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public void setKind(KindEnum kind) {
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BigCatAllOf bigCatAllOf = (BigCatAllOf) o;
|
||||
return Objects.equals(this.kind, bigCatAllOf.kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class BigCatAllOf {\n");
|
||||
|
||||
sb.append(" kind: ").append(toIndentedString(kind)).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(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user