forked from loafle/openapi-generator-original
Better handling of Inline schema (#15682)
* skip allOf inline subschema created as $ref * add option for fallback * add back atleastonemodel * add log * update java, kotlin, js samples * update tests * fix native client test * fix java client errors by regenerating test files * clean up python * clean up powershell * clean up php * clean up ruby * update erlang, elixir * update dart samples * update ts samples * update r, go samples * update perl * update swift * add back files * add back files * remove outdated test files * fix test
This commit is contained in:
@@ -18,15 +18,12 @@ docs/ArrayOfArrayOfNumberOnly.md
|
||||
docs/ArrayOfNumberOnly.md
|
||||
docs/ArrayTest.md
|
||||
docs/BigCat.md
|
||||
docs/BigCatAllOf.md
|
||||
docs/Capitalization.md
|
||||
docs/Cat.md
|
||||
docs/CatAllOf.md
|
||||
docs/Category.md
|
||||
docs/ClassModel.md
|
||||
docs/Client.md
|
||||
docs/Dog.md
|
||||
docs/DogAllOf.md
|
||||
docs/EnumArrays.md
|
||||
docs/EnumClass.md
|
||||
docs/EnumTest.md
|
||||
@@ -109,15 +106,12 @@ src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
|
||||
src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
|
||||
src/main/java/org/openapitools/client/model/ArrayTest.java
|
||||
src/main/java/org/openapitools/client/model/BigCat.java
|
||||
src/main/java/org/openapitools/client/model/BigCatAllOf.java
|
||||
src/main/java/org/openapitools/client/model/Capitalization.java
|
||||
src/main/java/org/openapitools/client/model/Cat.java
|
||||
src/main/java/org/openapitools/client/model/CatAllOf.java
|
||||
src/main/java/org/openapitools/client/model/Category.java
|
||||
src/main/java/org/openapitools/client/model/ClassModel.java
|
||||
src/main/java/org/openapitools/client/model/Client.java
|
||||
src/main/java/org/openapitools/client/model/Dog.java
|
||||
src/main/java/org/openapitools/client/model/DogAllOf.java
|
||||
src/main/java/org/openapitools/client/model/EnumArrays.java
|
||||
src/main/java/org/openapitools/client/model/EnumClass.java
|
||||
src/main/java/org/openapitools/client/model/EnumTest.java
|
||||
|
||||
@@ -167,15 +167,12 @@ Class | Method | HTTP request | Description
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [BigCat](docs/BigCat.md)
|
||||
- [BigCatAllOf](docs/BigCatAllOf.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [CatAllOf](docs/CatAllOf.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
- [DogAllOf](docs/DogAllOf.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
|
||||
# BigCatAllOf
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**kind** | [**KindEnum**](#KindEnum) | | [optional] |
|
||||
|
||||
|
||||
|
||||
## Enum: KindEnum
|
||||
|
||||
| Name | Value |
|
||||
|---- | -----|
|
||||
| LIONS | "lions" |
|
||||
| TIGERS | "tigers" |
|
||||
| LEOPARDS | "leopards" |
|
||||
| JAGUARS | "jaguars" |
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# CatAllOf
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**declawed** | **Boolean** | | [optional] |
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# DogAllOf
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Name | Type | Description | Notes |
|
||||
|------------ | ------------- | ------------- | -------------|
|
||||
|**breed** | **String** | | [optional] |
|
||||
|
||||
|
||||
|
||||
@@ -145,14 +145,11 @@ public class JSON {
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ArrayOfNumberOnly.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ArrayTest.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.BigCat.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.BigCatAllOf.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Capitalization.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.CatAllOf.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.ClassModel.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Client.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.Dog.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.DogAllOf.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.EnumArrays.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.EnumTest.CustomTypeAdapterFactory());
|
||||
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.client.model.FileSchemaTestClass.CustomTypeAdapterFactory());
|
||||
|
||||
@@ -1,259 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* BigCatAllOf
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class BigCatAllOf {
|
||||
/**
|
||||
* Gets or Sets kind
|
||||
*/
|
||||
@JsonAdapter(KindEnum.Adapter.class)
|
||||
public enum KindEnum {
|
||||
LIONS("lions"),
|
||||
|
||||
TIGERS("tigers"),
|
||||
|
||||
LEOPARDS("leopards"),
|
||||
|
||||
JAGUARS("jaguars");
|
||||
|
||||
private String value;
|
||||
|
||||
KindEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static KindEnum fromValue(String value) {
|
||||
for (KindEnum b : KindEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
|
||||
public static class Adapter extends TypeAdapter<KindEnum> {
|
||||
@Override
|
||||
public void write(final JsonWriter jsonWriter, final KindEnum enumeration) throws IOException {
|
||||
jsonWriter.value(enumeration.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public KindEnum read(final JsonReader jsonReader) throws IOException {
|
||||
String value = jsonReader.nextString();
|
||||
return KindEnum.fromValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final String SERIALIZED_NAME_KIND = "kind";
|
||||
@SerializedName(SERIALIZED_NAME_KIND)
|
||||
private KindEnum kind;
|
||||
|
||||
public BigCatAllOf() {
|
||||
}
|
||||
|
||||
public BigCatAllOf kind(KindEnum kind) {
|
||||
|
||||
this.kind = kind;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get kind
|
||||
* @return kind
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
public KindEnum getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
|
||||
public void setKind(KindEnum kind) {
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(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(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
|
||||
public static HashSet<String> openapiFields;
|
||||
public static HashSet<String> openapiRequiredFields;
|
||||
|
||||
static {
|
||||
// a set of all properties/fields (JSON key names)
|
||||
openapiFields = new HashSet<String>();
|
||||
openapiFields.add("kind");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to BigCatAllOf
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!BigCatAllOf.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in BigCatAllOf is not found in the empty JSON string", BigCatAllOf.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!BigCatAllOf.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCatAllOf` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
if ((jsonObj.get("kind") != null && !jsonObj.get("kind").isJsonNull()) && !jsonObj.get("kind").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `kind` to be a primitive type in the JSON string but got `%s`", jsonObj.get("kind").toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!BigCatAllOf.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'BigCatAllOf' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<BigCatAllOf> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(BigCatAllOf.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<BigCatAllOf>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, BigCatAllOf value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigCatAllOf read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of BigCatAllOf given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of BigCatAllOf
|
||||
* @throws IOException if the JSON string is invalid with respect to BigCatAllOf
|
||||
*/
|
||||
public static BigCatAllOf fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, BigCatAllOf.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of BigCatAllOf to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* CatAllOf
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class CatAllOf {
|
||||
public static final String SERIALIZED_NAME_DECLAWED = "declawed";
|
||||
@SerializedName(SERIALIZED_NAME_DECLAWED)
|
||||
private Boolean declawed;
|
||||
|
||||
public CatAllOf() {
|
||||
}
|
||||
|
||||
public CatAllOf declawed(Boolean declawed) {
|
||||
|
||||
this.declawed = declawed;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get declawed
|
||||
* @return declawed
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
public Boolean getDeclawed() {
|
||||
return declawed;
|
||||
}
|
||||
|
||||
|
||||
public void setDeclawed(Boolean declawed) {
|
||||
this.declawed = declawed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
CatAllOf catAllOf = (CatAllOf) o;
|
||||
return Objects.equals(this.declawed, catAllOf.declawed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(declawed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class CatAllOf {\n");
|
||||
sb.append(" declawed: ").append(toIndentedString(declawed)).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 ");
|
||||
}
|
||||
|
||||
|
||||
public static HashSet<String> openapiFields;
|
||||
public static HashSet<String> openapiRequiredFields;
|
||||
|
||||
static {
|
||||
// a set of all properties/fields (JSON key names)
|
||||
openapiFields = new HashSet<String>();
|
||||
openapiFields.add("declawed");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to CatAllOf
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!CatAllOf.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in CatAllOf is not found in the empty JSON string", CatAllOf.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!CatAllOf.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CatAllOf` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!CatAllOf.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'CatAllOf' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<CatAllOf> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(CatAllOf.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<CatAllOf>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, CatAllOf value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CatAllOf read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of CatAllOf given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of CatAllOf
|
||||
* @throws IOException if the JSON string is invalid with respect to CatAllOf
|
||||
*/
|
||||
public static CatAllOf fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, CatAllOf.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of CatAllOf to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* DogAllOf
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
|
||||
public class DogAllOf {
|
||||
public static final String SERIALIZED_NAME_BREED = "breed";
|
||||
@SerializedName(SERIALIZED_NAME_BREED)
|
||||
private String breed;
|
||||
|
||||
public DogAllOf() {
|
||||
}
|
||||
|
||||
public DogAllOf breed(String breed) {
|
||||
|
||||
this.breed = breed;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get breed
|
||||
* @return breed
|
||||
**/
|
||||
@javax.annotation.Nullable
|
||||
public String getBreed() {
|
||||
return breed;
|
||||
}
|
||||
|
||||
|
||||
public void setBreed(String breed) {
|
||||
this.breed = breed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
DogAllOf dogAllOf = (DogAllOf) o;
|
||||
return Objects.equals(this.breed, dogAllOf.breed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(breed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class DogAllOf {\n");
|
||||
sb.append(" breed: ").append(toIndentedString(breed)).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 ");
|
||||
}
|
||||
|
||||
|
||||
public static HashSet<String> openapiFields;
|
||||
public static HashSet<String> openapiRequiredFields;
|
||||
|
||||
static {
|
||||
// a set of all properties/fields (JSON key names)
|
||||
openapiFields = new HashSet<String>();
|
||||
openapiFields.add("breed");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to DogAllOf
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!DogAllOf.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in DogAllOf is not found in the empty JSON string", DogAllOf.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!DogAllOf.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DogAllOf` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
if ((jsonObj.get("breed") != null && !jsonObj.get("breed").isJsonNull()) && !jsonObj.get("breed").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `breed` to be a primitive type in the JSON string but got `%s`", jsonObj.get("breed").toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!DogAllOf.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'DogAllOf' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<DogAllOf> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(DogAllOf.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<DogAllOf>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, DogAllOf value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DogAllOf read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of DogAllOf given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of DogAllOf
|
||||
* @throws IOException if the JSON string is invalid with respect to DogAllOf
|
||||
*/
|
||||
public static DogAllOf fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, DogAllOf.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of DogAllOf to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1364,15 +1364,29 @@ components:
|
||||
Dog:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Animal'
|
||||
- $ref: '#/components/schemas/Dog_allOf'
|
||||
- properties:
|
||||
breed:
|
||||
type: string
|
||||
type: object
|
||||
Cat:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Animal'
|
||||
- $ref: '#/components/schemas/Cat_allOf'
|
||||
- properties:
|
||||
declawed:
|
||||
type: boolean
|
||||
type: object
|
||||
BigCat:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Cat'
|
||||
- $ref: '#/components/schemas/BigCat_allOf'
|
||||
- properties:
|
||||
kind:
|
||||
enum:
|
||||
- lions
|
||||
- tigers
|
||||
- leopards
|
||||
- jaguars
|
||||
type: string
|
||||
type: object
|
||||
Animal:
|
||||
discriminator:
|
||||
propertyName: className
|
||||
@@ -2165,29 +2179,6 @@ components:
|
||||
required:
|
||||
- requiredFile
|
||||
type: object
|
||||
Dog_allOf:
|
||||
properties:
|
||||
breed:
|
||||
type: string
|
||||
type: object
|
||||
example: null
|
||||
Cat_allOf:
|
||||
properties:
|
||||
declawed:
|
||||
type: boolean
|
||||
type: object
|
||||
example: null
|
||||
BigCat_allOf:
|
||||
properties:
|
||||
kind:
|
||||
enum:
|
||||
- lions
|
||||
- tigers
|
||||
- leopards
|
||||
- jaguars
|
||||
type: string
|
||||
type: object
|
||||
example: null
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
flows:
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for BigCatAllOf
|
||||
*/
|
||||
public class BigCatAllOfTest {
|
||||
private final BigCatAllOf model = new BigCatAllOf();
|
||||
|
||||
/**
|
||||
* Model tests for BigCatAllOf
|
||||
*/
|
||||
@Test
|
||||
public void testBigCatAllOf() {
|
||||
// TODO: test BigCatAllOf
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'kind'
|
||||
*/
|
||||
@Test
|
||||
public void kindTest() {
|
||||
// TODO: test kind
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,15 +18,11 @@ import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import org.openapitools.client.model.BigCatAllOf;
|
||||
import org.openapitools.client.model.Cat;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for BigCat
|
||||
*/
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for CatAllOf
|
||||
*/
|
||||
public class CatAllOfTest {
|
||||
private final CatAllOf model = new CatAllOf();
|
||||
|
||||
/**
|
||||
* Model tests for CatAllOf
|
||||
*/
|
||||
@Test
|
||||
public void testCatAllOf() {
|
||||
// TODO: test CatAllOf
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'declawed'
|
||||
*/
|
||||
@Test
|
||||
public void declawedTest() {
|
||||
// TODO: test declawed
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for DogAllOf
|
||||
*/
|
||||
public class DogAllOfTest {
|
||||
private final DogAllOf model = new DogAllOf();
|
||||
|
||||
/**
|
||||
* Model tests for DogAllOf
|
||||
*/
|
||||
@Test
|
||||
public void testDogAllOf() {
|
||||
// TODO: test DogAllOf
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'breed'
|
||||
*/
|
||||
@Test
|
||||
public void breedTest() {
|
||||
// TODO: test breed
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user