forked from loafle/openapi-generator-original
[java][Okhttp] replace okhttp-gson with okhttp-gson-nextgen (#11538)
* replace okhttp-gson with okhttp-gson-nextgen * add new files * update doc * clean up pom * update test * restore error handling in doc * add back changes * uncomment tests * update samples
This commit is contained in:
@@ -94,6 +94,7 @@ src/main/java/org/openapitools/client/auth/OAuth.java
|
||||
src/main/java/org/openapitools/client/auth/OAuthFlow.java
|
||||
src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java
|
||||
src/main/java/org/openapitools/client/auth/RetryingOAuth.java
|
||||
src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
|
||||
src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
|
||||
src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
|
||||
src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
|
||||
|
||||
@@ -311,6 +311,16 @@
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>${jackson-databind-nullable-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
@@ -1169,6 +1169,7 @@ public class ApiClient {
|
||||
/**
|
||||
* Build HTTP call with the given options.
|
||||
*
|
||||
* @param baseUrl The base URL
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
|
||||
* @param queryParams The query parameters
|
||||
@@ -1191,6 +1192,7 @@ public class ApiClient {
|
||||
/**
|
||||
* Build an HTTP request with the given options.
|
||||
*
|
||||
* @param baseUrl The base URL
|
||||
* @param path The sub-path of the HTTP URL
|
||||
* @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE"
|
||||
* @param queryParams The query parameters
|
||||
@@ -1259,6 +1261,7 @@ public class ApiClient {
|
||||
/**
|
||||
* Build full URL by concatenating base path, the given sub path and query parameters.
|
||||
*
|
||||
* @param baseUrl The base URL
|
||||
* @param path The sub path
|
||||
* @param queryParams The query parameters
|
||||
* @param collectionQueryParams The collection query parameters
|
||||
@@ -1353,6 +1356,7 @@ public class ApiClient {
|
||||
* @param payload HTTP request body
|
||||
* @param method HTTP method
|
||||
* @param uri URI
|
||||
* @throws org.openapitools.client.ApiException If fails to update the parameters
|
||||
*/
|
||||
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams,
|
||||
Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
|
||||
|
||||
@@ -16,6 +16,8 @@ package org.openapitools.client;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
|
||||
/**
|
||||
* <p>ApiException class.</p>
|
||||
*/
|
||||
@@ -25,6 +27,8 @@ public class ApiException extends Exception {
|
||||
private int code = 0;
|
||||
private Map<String, List<String>> responseHeaders = null;
|
||||
private String responseBody = null;
|
||||
private Object errorObject = null;
|
||||
private GenericType errorObjectType = null;
|
||||
|
||||
/**
|
||||
* <p>Constructor for ApiException.</p>
|
||||
@@ -151,4 +155,40 @@ public class ApiException extends Exception {
|
||||
public String getResponseBody() {
|
||||
return responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error object type.
|
||||
*
|
||||
* @return Error object type
|
||||
*/
|
||||
public GenericType getErrorObjectType() {
|
||||
return errorObjectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the error object type.
|
||||
*
|
||||
* @param errorObjectType object type
|
||||
*/
|
||||
public void setErrorObjectType(GenericType errorObjectType) {
|
||||
this.errorObjectType = errorObjectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error object.
|
||||
*
|
||||
* @return Error object
|
||||
*/
|
||||
public Object getErrorObject() {
|
||||
return errorObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error object.
|
||||
*
|
||||
* @param errorObject Error object
|
||||
*/
|
||||
public void setErrorObject(Object errorObject) {
|
||||
this.errorObject = errorObject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import org.threeten.bp.format.DateTimeFormatter;
|
||||
|
||||
import org.openapitools.client.model.*;
|
||||
import okio.ByteString;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -41,54 +40,60 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/*
|
||||
* A JSON utility class
|
||||
*
|
||||
* NOTE: in the future, this class may be converted to static, which may break
|
||||
* backward-compatibility
|
||||
*/
|
||||
public class JSON {
|
||||
private Gson gson;
|
||||
private boolean isLenientOnJson = false;
|
||||
private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
|
||||
private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
|
||||
private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||
private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||
private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||
private static Gson gson;
|
||||
private static boolean isLenientOnJson = false;
|
||||
private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
|
||||
private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
|
||||
private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
|
||||
private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
|
||||
private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static GsonBuilder createGson() {
|
||||
GsonFireBuilder fireBuilder = new GsonFireBuilder()
|
||||
.registerTypeSelector(Animal.class, new TypeSelector<Animal>() {
|
||||
.registerTypeSelector(org.openapitools.client.model.Animal.class, new TypeSelector<org.openapitools.client.model.Animal>() {
|
||||
@Override
|
||||
public Class<? extends Animal> getClassForElement(JsonElement readElement) {
|
||||
public Class<? extends org.openapitools.client.model.Animal> getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
classByDiscriminatorValue.put("BigCat", BigCat.class);
|
||||
classByDiscriminatorValue.put("Cat", Cat.class);
|
||||
classByDiscriminatorValue.put("Dog", Dog.class);
|
||||
classByDiscriminatorValue.put("Animal", Animal.class);
|
||||
classByDiscriminatorValue.put("BigCat", org.openapitools.client.model.BigCat.class);
|
||||
classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class);
|
||||
classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class);
|
||||
classByDiscriminatorValue.put("Animal", org.openapitools.client.model.Animal.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "className"));
|
||||
}
|
||||
})
|
||||
.registerTypeSelector(BigCat.class, new TypeSelector<BigCat>() {
|
||||
.registerTypeSelector(org.openapitools.client.model.BigCat.class, new TypeSelector<org.openapitools.client.model.BigCat>() {
|
||||
@Override
|
||||
public Class<? extends BigCat> getClassForElement(JsonElement readElement) {
|
||||
public Class<? extends org.openapitools.client.model.BigCat> getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
classByDiscriminatorValue.put("BigCat", BigCat.class);
|
||||
classByDiscriminatorValue.put("BigCat", org.openapitools.client.model.BigCat.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "className"));
|
||||
}
|
||||
})
|
||||
.registerTypeSelector(Cat.class, new TypeSelector<Cat>() {
|
||||
.registerTypeSelector(org.openapitools.client.model.Cat.class, new TypeSelector<org.openapitools.client.model.Cat>() {
|
||||
@Override
|
||||
public Class<? extends Cat> getClassForElement(JsonElement readElement) {
|
||||
public Class<? extends org.openapitools.client.model.Cat> getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
classByDiscriminatorValue.put("BigCat", BigCat.class);
|
||||
classByDiscriminatorValue.put("Cat", Cat.class);
|
||||
classByDiscriminatorValue.put("BigCat", org.openapitools.client.model.BigCat.class);
|
||||
classByDiscriminatorValue.put("Cat", org.openapitools.client.model.Cat.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "className"));
|
||||
}
|
||||
})
|
||||
.registerTypeSelector(Dog.class, new TypeSelector<Dog>() {
|
||||
.registerTypeSelector(org.openapitools.client.model.Dog.class, new TypeSelector<org.openapitools.client.model.Dog>() {
|
||||
@Override
|
||||
public Class<? extends Dog> getClassForElement(JsonElement readElement) {
|
||||
public Class<? extends org.openapitools.client.model.Dog> getClassForElement(JsonElement readElement) {
|
||||
Map<String, Class> classByDiscriminatorValue = new HashMap<String, Class>();
|
||||
classByDiscriminatorValue.put("Dog", Dog.class);
|
||||
classByDiscriminatorValue.put("Dog", org.openapitools.client.model.Dog.class);
|
||||
return getClassByDiscriminator(classByDiscriminatorValue,
|
||||
getDiscriminatorValue(readElement, "className"));
|
||||
}
|
||||
@@ -121,13 +126,57 @@ public class JSON {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public JSON() {
|
||||
{
|
||||
gson = createGson()
|
||||
.registerTypeAdapter(Date.class, dateTypeAdapter)
|
||||
.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter)
|
||||
.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter)
|
||||
.registerTypeAdapter(LocalDate.class, localDateTypeAdapter)
|
||||
.registerTypeAdapter(byte[].class, byteArrayAdapter)
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesAnyType.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesArray.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesBoolean.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesClass.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesInteger.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesNumber.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesObject.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.AdditionalPropertiesString.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ArrayOfArrayOfNumberOnly.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ArrayOfNumberOnly.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ArrayTest.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.BigCat.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.BigCatAllOf.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Capitalization.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.CatAllOf.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Category.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ClassModel.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Client.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Dog.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.DogAllOf.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.EnumArrays.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.EnumTest.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.FileSchemaTestClass.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.FormatTest.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.HasOnlyReadOnly.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.MapTest.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.MixedPropertiesAndAdditionalPropertiesClass.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Model200Response.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ModelApiResponse.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ModelFile.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ModelList.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ModelReturn.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Name.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.NumberOnly.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Order.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.OuterComposite.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Pet.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.ReadOnlyFirst.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.SpecialModelName.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.Tag.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.TypeHolderDefault.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.TypeHolderExample.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.User.CustomTypeAdapterFactory())
|
||||
.registerTypeAdapterFactory(new org.openapitools.client.model.XmlItem.CustomTypeAdapterFactory())
|
||||
.create();
|
||||
}
|
||||
|
||||
@@ -136,7 +185,7 @@ public class JSON {
|
||||
*
|
||||
* @return Gson
|
||||
*/
|
||||
public Gson getGson() {
|
||||
public static Gson getGson() {
|
||||
return gson;
|
||||
}
|
||||
|
||||
@@ -144,23 +193,13 @@ public class JSON {
|
||||
* Set Gson.
|
||||
*
|
||||
* @param gson Gson
|
||||
* @return JSON
|
||||
*/
|
||||
public JSON setGson(Gson gson) {
|
||||
this.gson = gson;
|
||||
return this;
|
||||
public static void setGson(Gson gson) {
|
||||
JSON.gson = gson;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the parser to be liberal in what it accepts.
|
||||
*
|
||||
* @param lenientOnJson Set it to true to ignore some syntax errors
|
||||
* @return JSON
|
||||
* @see <a href="https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html">https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html</a>
|
||||
*/
|
||||
public JSON setLenientOnJson(boolean lenientOnJson) {
|
||||
public static void setLenientOnJson(boolean lenientOnJson) {
|
||||
isLenientOnJson = lenientOnJson;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +208,7 @@ public class JSON {
|
||||
* @param obj Object
|
||||
* @return String representation of the JSON
|
||||
*/
|
||||
public String serialize(Object obj) {
|
||||
public static String serialize(Object obj) {
|
||||
return gson.toJson(obj);
|
||||
}
|
||||
|
||||
@@ -182,11 +221,11 @@ public class JSON {
|
||||
* @return The deserialized Java object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T deserialize(String body, Type returnType) {
|
||||
public static <T> T deserialize(String body, Type returnType) {
|
||||
try {
|
||||
if (isLenientOnJson) {
|
||||
JsonReader jsonReader = new JsonReader(new StringReader(body));
|
||||
// see https://www.javadoc.io/doc/com.google.code.gson/gson/2.8.5/com/google/gson/stream/JsonReader.html
|
||||
// see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
|
||||
jsonReader.setLenient(true);
|
||||
return gson.fromJson(jsonReader, returnType);
|
||||
} else {
|
||||
@@ -206,7 +245,7 @@ public class JSON {
|
||||
/**
|
||||
* Gson TypeAdapter for Byte Array type
|
||||
*/
|
||||
public class ByteArrayAdapter extends TypeAdapter<byte[]> {
|
||||
public static class ByteArrayAdapter extends TypeAdapter<byte[]> {
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter out, byte[] value) throws IOException {
|
||||
@@ -278,7 +317,7 @@ public class JSON {
|
||||
/**
|
||||
* Gson TypeAdapter for JSR310 LocalDate type
|
||||
*/
|
||||
public class LocalDateTypeAdapter extends TypeAdapter<LocalDate> {
|
||||
public static class LocalDateTypeAdapter extends TypeAdapter<LocalDate> {
|
||||
|
||||
private DateTimeFormatter formatter;
|
||||
|
||||
@@ -316,14 +355,12 @@ public class JSON {
|
||||
}
|
||||
}
|
||||
|
||||
public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
|
||||
public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
|
||||
offsetDateTimeTypeAdapter.setFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSON setLocalDateFormat(DateTimeFormatter dateFormat) {
|
||||
public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
|
||||
localDateTypeAdapter.setFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,14 +474,11 @@ public class JSON {
|
||||
}
|
||||
}
|
||||
|
||||
public JSON setDateFormat(DateFormat dateFormat) {
|
||||
public static void setDateFormat(DateFormat dateFormat) {
|
||||
dateTypeAdapter.setFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
public JSON setSqlDateFormat(DateFormat dateFormat) {
|
||||
public static void setSqlDateFormat(DateFormat dateFormat) {
|
||||
sqlDateTypeAdapter.setFormat(dateFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.GenericType;
|
||||
|
||||
public class AnotherFakeApi {
|
||||
private ApiClient localVarApiClient;
|
||||
@@ -89,7 +90,6 @@ public class AnotherFakeApi {
|
||||
*/
|
||||
public okhttp3.Call call123testSpecialTagsCall(Client body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -186,8 +186,14 @@ public class AnotherFakeApi {
|
||||
*/
|
||||
public ApiResponse<Client> call123testSpecialTagsWithHttpInfo(Client body) throws ApiException {
|
||||
okhttp3.Call localVarCall = call123testSpecialTagsValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Client>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Client>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,6 +45,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.GenericType;
|
||||
|
||||
public class FakeApi {
|
||||
private ApiClient localVarApiClient;
|
||||
@@ -97,7 +98,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call createXmlItemCall(XmlItem xmlItem, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -228,7 +228,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call fakeOuterBooleanSerializeCall(Boolean body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -320,8 +319,14 @@ public class FakeApi {
|
||||
*/
|
||||
public ApiResponse<Boolean> fakeOuterBooleanSerializeWithHttpInfo(Boolean body) throws ApiException {
|
||||
okhttp3.Call localVarCall = fakeOuterBooleanSerializeValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<Boolean>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Boolean>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Boolean>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Boolean>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,7 +363,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call fakeOuterCompositeSerializeCall(OuterComposite body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -450,8 +454,14 @@ public class FakeApi {
|
||||
*/
|
||||
public ApiResponse<OuterComposite> fakeOuterCompositeSerializeWithHttpInfo(OuterComposite body) throws ApiException {
|
||||
okhttp3.Call localVarCall = fakeOuterCompositeSerializeValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<OuterComposite>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<OuterComposite>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<OuterComposite>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<OuterComposite>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,7 +498,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call fakeOuterNumberSerializeCall(BigDecimal body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -580,8 +589,14 @@ public class FakeApi {
|
||||
*/
|
||||
public ApiResponse<BigDecimal> fakeOuterNumberSerializeWithHttpInfo(BigDecimal body) throws ApiException {
|
||||
okhttp3.Call localVarCall = fakeOuterNumberSerializeValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<BigDecimal>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<BigDecimal>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<BigDecimal>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<BigDecimal>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -618,7 +633,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call fakeOuterStringSerializeCall(String body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -710,8 +724,14 @@ public class FakeApi {
|
||||
*/
|
||||
public ApiResponse<String> fakeOuterStringSerializeWithHttpInfo(String body) throws ApiException {
|
||||
okhttp3.Call localVarCall = fakeOuterStringSerializeValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<String>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<String>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<String>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<String>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -748,7 +768,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testBodyWithFileSchemaCall(FileSchemaTestClass body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -880,7 +899,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testBodyWithQueryParamsCall(String query, User body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1020,7 +1038,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testClientModelCall(Client body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1117,8 +1134,14 @@ public class FakeApi {
|
||||
*/
|
||||
public ApiResponse<Client> testClientModelWithHttpInfo(Client body) throws ApiException {
|
||||
okhttp3.Call localVarCall = testClientModelValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Client>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Client>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1169,7 +1192,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testEndpointParametersCall(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, File binary, LocalDate date, OffsetDateTime dateTime, String password, String paramCallback, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1421,7 +1443,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testEnumParametersCall(List<String> enumHeaderStringArray, String enumHeaderString, List<String> enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble, List<String> enumFormStringArray, String enumFormString, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1573,7 +1594,6 @@ public class FakeApi {
|
||||
}
|
||||
private okhttp3.Call testGroupParametersCall(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1800,7 +1820,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testInlineAdditionalPropertiesCall(Map<String, String> param, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1932,7 +1951,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testJsonFormDataCall(String param, String param2, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -2083,7 +2101,6 @@ public class FakeApi {
|
||||
*/
|
||||
public okhttp3.Call testQueryParameterCollectionFormatCall(List<String> pipe, List<String> ioutil, List<String> http, List<String> url, List<String> context, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.GenericType;
|
||||
|
||||
public class FakeClassnameTags123Api {
|
||||
private ApiClient localVarApiClient;
|
||||
@@ -89,7 +90,6 @@ public class FakeClassnameTags123Api {
|
||||
*/
|
||||
public okhttp3.Call testClassnameCall(Client body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -186,8 +186,14 @@ public class FakeClassnameTags123Api {
|
||||
*/
|
||||
public ApiResponse<Client> testClassnameWithHttpInfo(Client body) throws ApiException {
|
||||
okhttp3.Call localVarCall = testClassnameValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Client>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Client>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Client>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.GenericType;
|
||||
|
||||
public class PetApi {
|
||||
private ApiClient localVarApiClient;
|
||||
@@ -93,7 +94,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call addPetCall(Pet body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -229,7 +229,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call deletePetCall(Long petId, String apiKey, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -369,7 +368,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call findPetsByStatusCall(List<String> status, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -469,8 +467,14 @@ public class PetApi {
|
||||
*/
|
||||
public ApiResponse<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status) throws ApiException {
|
||||
okhttp3.Call localVarCall = findPetsByStatusValidateBeforeCall(status, null);
|
||||
Type localVarReturnType = new TypeToken<List<Pet>>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<List<Pet>>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<List<Pet>>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<List<Pet>>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -511,7 +515,6 @@ public class PetApi {
|
||||
@Deprecated
|
||||
public okhttp3.Call findPetsByTagsCall(Set<String> tags, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -616,8 +619,14 @@ public class PetApi {
|
||||
@Deprecated
|
||||
public ApiResponse<Set<Pet>> findPetsByTagsWithHttpInfo(Set<String> tags) throws ApiException {
|
||||
okhttp3.Call localVarCall = findPetsByTagsValidateBeforeCall(tags, null);
|
||||
Type localVarReturnType = new TypeToken<Set<Pet>>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Set<Pet>>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Set<Pet>>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Set<Pet>>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -659,7 +668,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call getPetByIdCall(Long petId, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -761,8 +769,14 @@ public class PetApi {
|
||||
*/
|
||||
public ApiResponse<Pet> getPetByIdWithHttpInfo(Long petId) throws ApiException {
|
||||
okhttp3.Call localVarCall = getPetByIdValidateBeforeCall(petId, null);
|
||||
Type localVarReturnType = new TypeToken<Pet>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Pet>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Pet>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Pet>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -804,7 +818,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call updatePetCall(Pet body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -946,7 +959,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call updatePetWithFormCall(Long petId, String name, String status, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1094,7 +1106,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call uploadFileCall(Long petId, String additionalMetadata, File _file, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1204,8 +1215,14 @@ public class PetApi {
|
||||
*/
|
||||
public ApiResponse<ModelApiResponse> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File _file) throws ApiException {
|
||||
okhttp3.Call localVarCall = uploadFileValidateBeforeCall(petId, additionalMetadata, _file, null);
|
||||
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<ModelApiResponse>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<ModelApiResponse>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1246,7 +1263,6 @@ public class PetApi {
|
||||
*/
|
||||
public okhttp3.Call uploadFileWithRequiredFileCall(Long petId, File requiredFile, String additionalMetadata, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1361,8 +1377,14 @@ public class PetApi {
|
||||
*/
|
||||
public ApiResponse<ModelApiResponse> uploadFileWithRequiredFileWithHttpInfo(Long petId, File requiredFile, String additionalMetadata) throws ApiException {
|
||||
okhttp3.Call localVarCall = uploadFileWithRequiredFileValidateBeforeCall(petId, requiredFile, additionalMetadata, null);
|
||||
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<ModelApiResponse>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<ModelApiResponse>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<ModelApiResponse>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.GenericType;
|
||||
|
||||
public class StoreApi {
|
||||
private ApiClient localVarApiClient;
|
||||
@@ -90,7 +91,6 @@ public class StoreApi {
|
||||
*/
|
||||
public okhttp3.Call deleteOrderCall(String orderId, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -224,7 +224,6 @@ public class StoreApi {
|
||||
*/
|
||||
public okhttp3.Call getInventoryCall(final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -314,8 +313,14 @@ public class StoreApi {
|
||||
*/
|
||||
public ApiResponse<Map<String, Integer>> getInventoryWithHttpInfo() throws ApiException {
|
||||
okhttp3.Call localVarCall = getInventoryValidateBeforeCall(null);
|
||||
Type localVarReturnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Map<String, Integer>>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Map<String, Integer>>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +358,6 @@ public class StoreApi {
|
||||
*/
|
||||
public okhttp3.Call getOrderByIdCall(Long orderId, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -455,8 +459,14 @@ public class StoreApi {
|
||||
*/
|
||||
public ApiResponse<Order> getOrderByIdWithHttpInfo(Long orderId) throws ApiException {
|
||||
okhttp3.Call localVarCall = getOrderByIdValidateBeforeCall(orderId, null);
|
||||
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Order>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Order>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -496,7 +506,6 @@ public class StoreApi {
|
||||
*/
|
||||
public okhttp3.Call placeOrderCall(Order body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -595,8 +604,14 @@ public class StoreApi {
|
||||
*/
|
||||
public ApiResponse<Order> placeOrderWithHttpInfo(Order body) throws ApiException {
|
||||
okhttp3.Call localVarCall = placeOrderValidateBeforeCall(body, null);
|
||||
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<Order>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<Order>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<Order>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.core.GenericType;
|
||||
|
||||
public class UserApi {
|
||||
private ApiClient localVarApiClient;
|
||||
@@ -90,7 +91,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call createUserCall(User body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -221,7 +221,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call createUsersWithArrayInputCall(List<User> body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -352,7 +351,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call createUsersWithListInputCall(List<User> body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -484,7 +482,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call deleteUserCall(String username, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -621,7 +618,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call getUserByNameCall(String username, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -723,8 +719,14 @@ public class UserApi {
|
||||
*/
|
||||
public ApiResponse<User> getUserByNameWithHttpInfo(String username) throws ApiException {
|
||||
okhttp3.Call localVarCall = getUserByNameValidateBeforeCall(username, null);
|
||||
Type localVarReturnType = new TypeToken<User>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<User>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<User>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<User>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -765,7 +767,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call loginUserCall(String username, String password, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -873,8 +874,14 @@ public class UserApi {
|
||||
*/
|
||||
public ApiResponse<String> loginUserWithHttpInfo(String username, String password) throws ApiException {
|
||||
okhttp3.Call localVarCall = loginUserValidateBeforeCall(username, password, null);
|
||||
Type localVarReturnType = new TypeToken<String>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
try {
|
||||
Type localVarReturnType = new TypeToken<String>(){}.getType();
|
||||
return localVarApiClient.execute(localVarCall, localVarReturnType);
|
||||
} catch (ApiException e) {
|
||||
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<String>(){}.getType()));
|
||||
e.setErrorObjectType(new GenericType<String>(){});
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -912,7 +919,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call logoutUserCall(final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
@@ -1037,7 +1043,6 @@ public class UserApi {
|
||||
*/
|
||||
public okhttp3.Call updateUserCall(String username, User body, final ApiCallback _callback) throws ApiException {
|
||||
String basePath = null;
|
||||
|
||||
// Operation Servers
|
||||
String[] localBasePaths = new String[] { };
|
||||
|
||||
|
||||
@@ -28,22 +28,31 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
|
||||
private TokenRequestBuilder tokenRequestBuilder;
|
||||
|
||||
/**
|
||||
* @param client An OkHttp client
|
||||
* @param tokenRequestBuilder A token request builder
|
||||
*/
|
||||
public RetryingOAuth(OkHttpClient client, TokenRequestBuilder tokenRequestBuilder) {
|
||||
this.oAuthClient = new OAuthClient(new OAuthOkHttpClient(client));
|
||||
this.tokenRequestBuilder = tokenRequestBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tokenRequestBuilder A token request builder
|
||||
*/
|
||||
public RetryingOAuth(TokenRequestBuilder tokenRequestBuilder) {
|
||||
this(new OkHttpClient(), tokenRequestBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
@param tokenUrl The token URL to be used for this OAuth2 flow.
|
||||
Applicable to the following OAuth2 flows: "password", "clientCredentials" and "authorizationCode".
|
||||
The value must be an absolute URL.
|
||||
@param clientId The OAuth2 client ID for the "clientCredentials" flow.
|
||||
@param clientSecret The OAuth2 client secret for the "clientCredentials" flow.
|
||||
*/
|
||||
* @param tokenUrl The token URL to be used for this OAuth2 flow.
|
||||
* Applicable to the following OAuth2 flows: "password", "clientCredentials" and "authorizationCode".
|
||||
* The value must be an absolute URL.
|
||||
* @param clientId The OAuth2 client ID for the "clientCredentials" flow.
|
||||
* @param flow OAuth flow.
|
||||
* @param clientSecret The OAuth2 client secret for the "clientCredentials" flow.
|
||||
* @param parameters A map of string.
|
||||
*/
|
||||
public RetryingOAuth(
|
||||
String tokenUrl,
|
||||
String clientId,
|
||||
@@ -62,6 +71,11 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the OAuth flow
|
||||
*
|
||||
* @param flow The OAuth flow.
|
||||
*/
|
||||
public void setFlow(OAuthFlow flow) {
|
||||
switch(flow) {
|
||||
case ACCESS_CODE:
|
||||
@@ -147,8 +161,12 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns true if the access token has been updated
|
||||
*
|
||||
* @param requestAccessToken the request access token
|
||||
* @return True if the update is successful
|
||||
* @throws java.io.IOException If fail to update the access token
|
||||
*/
|
||||
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
|
||||
if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
|
||||
@@ -165,10 +183,21 @@ public class RetryingOAuth extends OAuth implements Interceptor {
|
||||
return getAccessToken() == null || !getAccessToken().equals(requestAccessToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the token request builder
|
||||
*
|
||||
* @return A token request builder
|
||||
* @throws java.io.IOException If fail to update the access token
|
||||
*/
|
||||
public TokenRequestBuilder getTokenRequestBuilder() {
|
||||
return tokenRequestBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the token request builder
|
||||
*
|
||||
* @param tokenRequestBuilder Token request builder
|
||||
*/
|
||||
public void setTokenRequestBuilder(TokenRequestBuilder tokenRequestBuilder) {
|
||||
this.tokenRequestBuilder = tokenRequestBuilder;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesAnyType
|
||||
*/
|
||||
@@ -100,5 +119,89 @@ public class AdditionalPropertiesAnyType extends HashMap<String, Object> {
|
||||
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("name");
|
||||
|
||||
// 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 AdditionalPropertiesAnyType
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesAnyType.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.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 (!AdditionalPropertiesAnyType.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` 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 (!AdditionalPropertiesAnyType.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesAnyType' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesAnyType> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesAnyType.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesAnyType>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesAnyType given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesAnyType
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesAnyType
|
||||
*/
|
||||
public static AdditionalPropertiesAnyType fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesAnyType.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesAnyType to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesArray
|
||||
*/
|
||||
@@ -101,5 +120,89 @@ public class AdditionalPropertiesArray extends HashMap<String, List> {
|
||||
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("name");
|
||||
|
||||
// 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 AdditionalPropertiesArray
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesArray.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.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 (!AdditionalPropertiesArray.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` 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 (!AdditionalPropertiesArray.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesArray' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesArray> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesArray.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesArray>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesArray value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesArray read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesArray given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesArray
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesArray
|
||||
*/
|
||||
public static AdditionalPropertiesArray fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesArray.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesArray to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesBoolean
|
||||
*/
|
||||
@@ -100,5 +119,89 @@ public class AdditionalPropertiesBoolean extends HashMap<String, Boolean> {
|
||||
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("name");
|
||||
|
||||
// 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 AdditionalPropertiesBoolean
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesBoolean.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.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 (!AdditionalPropertiesBoolean.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` 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 (!AdditionalPropertiesBoolean.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesBoolean' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesBoolean> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesBoolean.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesBoolean>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesBoolean value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesBoolean read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesBoolean given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesBoolean
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesBoolean
|
||||
*/
|
||||
public static AdditionalPropertiesBoolean fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesBoolean.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesBoolean to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,25 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesClass
|
||||
*/
|
||||
@@ -454,5 +473,99 @@ public class AdditionalPropertiesClass {
|
||||
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("map_string");
|
||||
openapiFields.add("map_number");
|
||||
openapiFields.add("map_integer");
|
||||
openapiFields.add("map_boolean");
|
||||
openapiFields.add("map_array_integer");
|
||||
openapiFields.add("map_array_anytype");
|
||||
openapiFields.add("map_map_string");
|
||||
openapiFields.add("map_map_anytype");
|
||||
openapiFields.add("anytype_1");
|
||||
openapiFields.add("anytype_2");
|
||||
openapiFields.add("anytype_3");
|
||||
|
||||
// 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 AdditionalPropertiesClass
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesClass is not found in the empty JSON string", AdditionalPropertiesClass.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 (!AdditionalPropertiesClass.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` 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 (!AdditionalPropertiesClass.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesClass' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesClass> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesClass.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesClass>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesClass value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesClass read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesClass given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesClass
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesClass
|
||||
*/
|
||||
public static AdditionalPropertiesClass fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesClass.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesClass to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesInteger
|
||||
*/
|
||||
@@ -100,5 +119,89 @@ public class AdditionalPropertiesInteger extends HashMap<String, Integer> {
|
||||
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("name");
|
||||
|
||||
// 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 AdditionalPropertiesInteger
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesInteger.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.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 (!AdditionalPropertiesInteger.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` 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 (!AdditionalPropertiesInteger.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesInteger' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesInteger> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesInteger.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesInteger>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesInteger value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesInteger read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesInteger given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesInteger
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesInteger
|
||||
*/
|
||||
public static AdditionalPropertiesInteger fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesInteger.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesInteger to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesNumber
|
||||
*/
|
||||
@@ -101,5 +120,89 @@ public class AdditionalPropertiesNumber extends HashMap<String, BigDecimal> {
|
||||
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("name");
|
||||
|
||||
// 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 AdditionalPropertiesNumber
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesNumber.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.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 (!AdditionalPropertiesNumber.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` 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 (!AdditionalPropertiesNumber.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesNumber' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesNumber> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesNumber.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesNumber>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesNumber value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesNumber read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesNumber given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesNumber
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesNumber
|
||||
*/
|
||||
public static AdditionalPropertiesNumber fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesNumber.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesNumber to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesObject
|
||||
*/
|
||||
@@ -100,5 +119,89 @@ public class AdditionalPropertiesObject extends HashMap<String, Map> {
|
||||
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("name");
|
||||
|
||||
// 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 AdditionalPropertiesObject
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesObject.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.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 (!AdditionalPropertiesObject.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` 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 (!AdditionalPropertiesObject.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesObject' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesObject> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesObject.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesObject>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesObject read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesObject given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesObject
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesObject
|
||||
*/
|
||||
public static AdditionalPropertiesObject fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesObject.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesObject to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesString
|
||||
*/
|
||||
@@ -100,5 +119,89 @@ public class AdditionalPropertiesString extends HashMap<String, String> {
|
||||
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("name");
|
||||
|
||||
// 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 AdditionalPropertiesString
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (AdditionalPropertiesString.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.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 (!AdditionalPropertiesString.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` 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 (!AdditionalPropertiesString.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'AdditionalPropertiesString' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<AdditionalPropertiesString> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(AdditionalPropertiesString.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<AdditionalPropertiesString>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesString value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesString read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of AdditionalPropertiesString given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of AdditionalPropertiesString
|
||||
* @throws IOException if the JSON string is invalid with respect to AdditionalPropertiesString
|
||||
*/
|
||||
public static AdditionalPropertiesString fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, AdditionalPropertiesString.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of AdditionalPropertiesString to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import org.openapitools.client.model.BigCat;
|
||||
import org.openapitools.client.model.Cat;
|
||||
import org.openapitools.client.model.Dog;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Animal
|
||||
*/
|
||||
@@ -129,5 +148,71 @@ public class Animal {
|
||||
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("className");
|
||||
openapiFields.add("color");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("className");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Animal
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Animal.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Animal is not found in the empty JSON string", Animal.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
String discriminatorValue = jsonObj.get("className").getAsString();
|
||||
switch (discriminatorValue) {
|
||||
case "BigCat":
|
||||
BigCat.validateJsonObject(jsonObj);
|
||||
break;
|
||||
case "Cat":
|
||||
Cat.validateJsonObject(jsonObj);
|
||||
break;
|
||||
case "Dog":
|
||||
Dog.validateJsonObject(jsonObj);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance of Animal given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Animal
|
||||
* @throws IOException if the JSON string is invalid with respect to Animal
|
||||
*/
|
||||
public static Animal fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Animal.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Animal to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
@@ -107,5 +126,89 @@ public class ArrayOfArrayOfNumberOnly {
|
||||
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("ArrayArrayNumber");
|
||||
|
||||
// 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 ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfArrayOfNumberOnly is not found in the empty JSON string", ArrayOfArrayOfNumberOnly.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 (!ArrayOfArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` 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 (!ArrayOfArrayOfNumberOnly.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ArrayOfArrayOfNumberOnly' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ArrayOfArrayOfNumberOnly> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ArrayOfArrayOfNumberOnly.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ArrayOfArrayOfNumberOnly>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ArrayOfArrayOfNumberOnly value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayOfArrayOfNumberOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ArrayOfArrayOfNumberOnly given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ArrayOfArrayOfNumberOnly
|
||||
* @throws IOException if the JSON string is invalid with respect to ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
public static ArrayOfArrayOfNumberOnly fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ArrayOfArrayOfNumberOnly.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ArrayOfArrayOfNumberOnly to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* ArrayOfNumberOnly
|
||||
*/
|
||||
@@ -107,5 +126,89 @@ public class ArrayOfNumberOnly {
|
||||
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("ArrayNumber");
|
||||
|
||||
// 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 ArrayOfNumberOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfNumberOnly is not found in the empty JSON string", ArrayOfNumberOnly.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 (!ArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` 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 (!ArrayOfNumberOnly.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ArrayOfNumberOnly' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ArrayOfNumberOnly> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ArrayOfNumberOnly.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ArrayOfNumberOnly>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ArrayOfNumberOnly value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayOfNumberOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ArrayOfNumberOnly given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ArrayOfNumberOnly
|
||||
* @throws IOException if the JSON string is invalid with respect to ArrayOfNumberOnly
|
||||
*/
|
||||
public static ArrayOfNumberOnly fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ArrayOfNumberOnly.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ArrayOfNumberOnly to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.ReadOnlyFirst;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* ArrayTest
|
||||
*/
|
||||
@@ -181,5 +200,91 @@ public class ArrayTest {
|
||||
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("array_of_string");
|
||||
openapiFields.add("array_array_of_integer");
|
||||
openapiFields.add("array_array_of_model");
|
||||
|
||||
// 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 ArrayTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ArrayTest.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayTest is not found in the empty JSON string", ArrayTest.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 (!ArrayTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` 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 (!ArrayTest.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ArrayTest' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ArrayTest> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ArrayTest.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ArrayTest>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ArrayTest value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ArrayTest given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ArrayTest
|
||||
* @throws IOException if the JSON string is invalid with respect to ArrayTest
|
||||
*/
|
||||
public static ArrayTest fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ArrayTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ArrayTest to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import org.openapitools.client.model.BigCatAllOf;
|
||||
import org.openapitools.client.model.Cat;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* BigCat
|
||||
*/
|
||||
@@ -152,5 +171,100 @@ public class BigCat extends Cat {
|
||||
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("className");
|
||||
openapiFields.add("color");
|
||||
openapiFields.add("declawed");
|
||||
openapiFields.add("kind");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("className");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 BigCat
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (BigCat.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in BigCat is not found in the empty JSON string", BigCat.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 (!BigCat.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCat` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : BigCat.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!BigCat.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'BigCat' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<BigCat> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(BigCat.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<BigCat>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, BigCat value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigCat read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of BigCat given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of BigCat
|
||||
* @throws IOException if the JSON string is invalid with respect to BigCat
|
||||
*/
|
||||
public static BigCat fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, BigCat.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of BigCat to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* BigCatAllOf
|
||||
*/
|
||||
@@ -147,5 +166,89 @@ public class BigCatAllOf {
|
||||
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()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Capitalization
|
||||
*/
|
||||
@@ -241,5 +260,94 @@ public class Capitalization {
|
||||
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("smallCamel");
|
||||
openapiFields.add("CapitalCamel");
|
||||
openapiFields.add("small_Snake");
|
||||
openapiFields.add("Capital_Snake");
|
||||
openapiFields.add("SCA_ETH_Flow_Points");
|
||||
openapiFields.add("ATT_NAME");
|
||||
|
||||
// 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 Capitalization
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Capitalization.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Capitalization is not found in the empty JSON string", Capitalization.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 (!Capitalization.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` 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 (!Capitalization.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Capitalization' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Capitalization> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Capitalization.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Capitalization>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Capitalization value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Capitalization read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Capitalization given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Capitalization
|
||||
* @throws IOException if the JSON string is invalid with respect to Capitalization
|
||||
*/
|
||||
public static Capitalization fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Capitalization.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Capitalization to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import org.openapitools.client.model.Animal;
|
||||
import org.openapitools.client.model.BigCat;
|
||||
import org.openapitools.client.model.CatAllOf;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Cat
|
||||
*/
|
||||
@@ -102,5 +121,66 @@ public class Cat extends Animal {
|
||||
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("className");
|
||||
openapiFields.add("color");
|
||||
openapiFields.add("declawed");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("className");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Cat
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Cat.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Cat is not found in the empty JSON string", Cat.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
String discriminatorValue = jsonObj.get("className").getAsString();
|
||||
switch (discriminatorValue) {
|
||||
case "BigCat":
|
||||
BigCat.validateJsonObject(jsonObj);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance of Cat given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Cat
|
||||
* @throws IOException if the JSON string is invalid with respect to Cat
|
||||
*/
|
||||
public static Cat fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Cat.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Cat to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* CatAllOf
|
||||
*/
|
||||
@@ -96,5 +115,89 @@ public class CatAllOf {
|
||||
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()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Category
|
||||
*/
|
||||
@@ -125,5 +144,98 @@ public class Category {
|
||||
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("id");
|
||||
openapiFields.add("name");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("name");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Category
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Category.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Category is not found in the empty JSON string", Category.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 (!Category.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Category.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!Category.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Category' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Category> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Category.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Category>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Category value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Category given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Category
|
||||
* @throws IOException if the JSON string is invalid with respect to Category
|
||||
*/
|
||||
public static Category fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Category.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Category to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Model for testing model with \"_class\" property
|
||||
*/
|
||||
@@ -97,5 +116,89 @@ public class ClassModel {
|
||||
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("_class");
|
||||
|
||||
// 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 ClassModel
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ClassModel.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ClassModel is not found in the empty JSON string", ClassModel.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 (!ClassModel.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` 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 (!ClassModel.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ClassModel' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ClassModel> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ClassModel.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ClassModel>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ClassModel value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassModel read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ClassModel given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ClassModel
|
||||
* @throws IOException if the JSON string is invalid with respect to ClassModel
|
||||
*/
|
||||
public static ClassModel fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ClassModel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ClassModel to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Client
|
||||
*/
|
||||
@@ -96,5 +115,89 @@ public class Client {
|
||||
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("client");
|
||||
|
||||
// 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 Client
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Client.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Client is not found in the empty JSON string", Client.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 (!Client.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` 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 (!Client.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Client' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Client> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Client.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Client>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Client value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Client read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Client given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Client
|
||||
* @throws IOException if the JSON string is invalid with respect to Client
|
||||
*/
|
||||
public static Client fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Client.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Client to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import org.openapitools.client.model.DogAllOf;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Dog
|
||||
*/
|
||||
@@ -101,5 +120,99 @@ public class Dog extends Animal {
|
||||
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("className");
|
||||
openapiFields.add("color");
|
||||
openapiFields.add("breed");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("className");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Dog
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Dog.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Dog is not found in the empty JSON string", Dog.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 (!Dog.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Dog.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!Dog.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Dog' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Dog> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Dog.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Dog>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Dog value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dog read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Dog given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Dog
|
||||
* @throws IOException if the JSON string is invalid with respect to Dog
|
||||
*/
|
||||
public static Dog fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Dog.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Dog to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* DogAllOf
|
||||
*/
|
||||
@@ -96,5 +115,89 @@ public class DogAllOf {
|
||||
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()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,25 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* EnumArrays
|
||||
*/
|
||||
@@ -229,5 +248,90 @@ public class EnumArrays {
|
||||
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("just_symbol");
|
||||
openapiFields.add("array_enum");
|
||||
|
||||
// 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 EnumArrays
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (EnumArrays.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumArrays is not found in the empty JSON string", EnumArrays.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 (!EnumArrays.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` 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 (!EnumArrays.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'EnumArrays' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<EnumArrays> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(EnumArrays.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<EnumArrays>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, EnumArrays value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumArrays read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of EnumArrays given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of EnumArrays
|
||||
* @throws IOException if the JSON string is invalid with respect to EnumArrays
|
||||
*/
|
||||
public static EnumArrays fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, EnumArrays.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of EnumArrays to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,25 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import org.openapitools.client.model.OuterEnum;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* EnumTest
|
||||
*/
|
||||
@@ -405,5 +424,101 @@ public class EnumTest {
|
||||
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("enum_string");
|
||||
openapiFields.add("enum_string_required");
|
||||
openapiFields.add("enum_integer");
|
||||
openapiFields.add("enum_number");
|
||||
openapiFields.add("outerEnum");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("enum_string_required");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 EnumTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (EnumTest.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumTest is not found in the empty JSON string", EnumTest.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 (!EnumTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : EnumTest.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!EnumTest.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'EnumTest' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<EnumTest> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(EnumTest.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<EnumTest>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, EnumTest value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of EnumTest given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of EnumTest
|
||||
* @throws IOException if the JSON string is invalid with respect to EnumTest
|
||||
*/
|
||||
public static EnumTest fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, EnumTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of EnumTest to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.ModelFile;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* FileSchemaTestClass
|
||||
*/
|
||||
@@ -136,5 +155,101 @@ public class FileSchemaTestClass {
|
||||
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("file");
|
||||
openapiFields.add("files");
|
||||
|
||||
// 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 FileSchemaTestClass
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (FileSchemaTestClass.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in FileSchemaTestClass is not found in the empty JSON string", FileSchemaTestClass.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 (!FileSchemaTestClass.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileSchemaTestClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
// validate the optional field `file`
|
||||
if (jsonObj.getAsJsonObject("file") != null) {
|
||||
ModelFile.validateJsonObject(jsonObj.getAsJsonObject("file"));
|
||||
}
|
||||
JsonArray jsonArrayfiles = jsonObj.getAsJsonArray("files");
|
||||
// validate the optional field `files` (array)
|
||||
if (jsonArrayfiles != null) {
|
||||
for (int i = 0; i < jsonArrayfiles.size(); i++) {
|
||||
ModelFile.validateJsonObject(jsonArrayfiles.get(i).getAsJsonObject());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!FileSchemaTestClass.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'FileSchemaTestClass' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<FileSchemaTestClass> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(FileSchemaTestClass.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<FileSchemaTestClass>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, FileSchemaTestClass value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileSchemaTestClass read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of FileSchemaTestClass given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of FileSchemaTestClass
|
||||
* @throws IOException if the JSON string is invalid with respect to FileSchemaTestClass
|
||||
*/
|
||||
public static FileSchemaTestClass fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, FileSchemaTestClass.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of FileSchemaTestClass to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,25 @@ import java.util.UUID;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* FormatTest
|
||||
*/
|
||||
@@ -488,5 +507,113 @@ public class FormatTest {
|
||||
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("integer");
|
||||
openapiFields.add("int32");
|
||||
openapiFields.add("int64");
|
||||
openapiFields.add("number");
|
||||
openapiFields.add("float");
|
||||
openapiFields.add("double");
|
||||
openapiFields.add("string");
|
||||
openapiFields.add("byte");
|
||||
openapiFields.add("binary");
|
||||
openapiFields.add("date");
|
||||
openapiFields.add("dateTime");
|
||||
openapiFields.add("uuid");
|
||||
openapiFields.add("password");
|
||||
openapiFields.add("BigDecimal");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("number");
|
||||
openapiRequiredFields.add("byte");
|
||||
openapiRequiredFields.add("date");
|
||||
openapiRequiredFields.add("password");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 FormatTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (FormatTest.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in FormatTest is not found in the empty JSON string", FormatTest.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 (!FormatTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FormatTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : FormatTest.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!FormatTest.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'FormatTest' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<FormatTest> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(FormatTest.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<FormatTest>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, FormatTest value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FormatTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of FormatTest given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of FormatTest
|
||||
* @throws IOException if the JSON string is invalid with respect to FormatTest
|
||||
*/
|
||||
public static FormatTest fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, FormatTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of FormatTest to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* HasOnlyReadOnly
|
||||
*/
|
||||
@@ -117,5 +136,90 @@ public class HasOnlyReadOnly {
|
||||
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("bar");
|
||||
openapiFields.add("foo");
|
||||
|
||||
// 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 HasOnlyReadOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (HasOnlyReadOnly.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in HasOnlyReadOnly is not found in the empty JSON string", HasOnlyReadOnly.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 (!HasOnlyReadOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HasOnlyReadOnly` 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 (!HasOnlyReadOnly.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'HasOnlyReadOnly' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<HasOnlyReadOnly> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(HasOnlyReadOnly.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<HasOnlyReadOnly>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, HasOnlyReadOnly value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HasOnlyReadOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of HasOnlyReadOnly given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of HasOnlyReadOnly
|
||||
* @throws IOException if the JSON string is invalid with respect to HasOnlyReadOnly
|
||||
*/
|
||||
public static HasOnlyReadOnly fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, HasOnlyReadOnly.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of HasOnlyReadOnly to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* MapTest
|
||||
*/
|
||||
@@ -265,5 +284,92 @@ public class MapTest {
|
||||
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("map_map_of_string");
|
||||
openapiFields.add("map_of_enum_string");
|
||||
openapiFields.add("direct_map");
|
||||
openapiFields.add("indirect_map");
|
||||
|
||||
// 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 MapTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (MapTest.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in MapTest is not found in the empty JSON string", MapTest.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 (!MapTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MapTest` 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 (!MapTest.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'MapTest' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<MapTest> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(MapTest.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<MapTest>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, MapTest value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of MapTest given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of MapTest
|
||||
* @throws IOException if the JSON string is invalid with respect to MapTest
|
||||
*/
|
||||
public static MapTest fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, MapTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of MapTest to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,25 @@ import java.util.UUID;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
@@ -168,5 +187,91 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
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("uuid");
|
||||
openapiFields.add("dateTime");
|
||||
openapiFields.add("map");
|
||||
|
||||
// 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 MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in MixedPropertiesAndAdditionalPropertiesClass is not found in the empty JSON string", MixedPropertiesAndAdditionalPropertiesClass.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 (!MixedPropertiesAndAdditionalPropertiesClass.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MixedPropertiesAndAdditionalPropertiesClass` 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 (!MixedPropertiesAndAdditionalPropertiesClass.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'MixedPropertiesAndAdditionalPropertiesClass' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<MixedPropertiesAndAdditionalPropertiesClass> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(MixedPropertiesAndAdditionalPropertiesClass.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<MixedPropertiesAndAdditionalPropertiesClass>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, MixedPropertiesAndAdditionalPropertiesClass value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MixedPropertiesAndAdditionalPropertiesClass read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of MixedPropertiesAndAdditionalPropertiesClass given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of MixedPropertiesAndAdditionalPropertiesClass
|
||||
* @throws IOException if the JSON string is invalid with respect to MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
public static MixedPropertiesAndAdditionalPropertiesClass fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, MixedPropertiesAndAdditionalPropertiesClass.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of MixedPropertiesAndAdditionalPropertiesClass to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Model for testing model name starting with number
|
||||
*/
|
||||
@@ -126,5 +145,90 @@ public class Model200Response {
|
||||
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("name");
|
||||
openapiFields.add("class");
|
||||
|
||||
// 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 Model200Response
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Model200Response.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Model200Response is not found in the empty JSON string", Model200Response.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 (!Model200Response.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Model200Response` 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 (!Model200Response.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Model200Response' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Model200Response> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Model200Response.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Model200Response>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Model200Response value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model200Response read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Model200Response given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Model200Response
|
||||
* @throws IOException if the JSON string is invalid with respect to Model200Response
|
||||
*/
|
||||
public static Model200Response fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Model200Response.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Model200Response to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* ModelApiResponse
|
||||
*/
|
||||
@@ -154,5 +173,91 @@ public class ModelApiResponse {
|
||||
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("code");
|
||||
openapiFields.add("type");
|
||||
openapiFields.add("message");
|
||||
|
||||
// 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 ModelApiResponse
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ModelApiResponse.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelApiResponse is not found in the empty JSON string", ModelApiResponse.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 (!ModelApiResponse.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelApiResponse` 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 (!ModelApiResponse.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ModelApiResponse' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ModelApiResponse> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ModelApiResponse.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ModelApiResponse>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ModelApiResponse value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelApiResponse read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ModelApiResponse given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ModelApiResponse
|
||||
* @throws IOException if the JSON string is invalid with respect to ModelApiResponse
|
||||
*/
|
||||
public static ModelApiResponse fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ModelApiResponse.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ModelApiResponse to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Must be named `File` for test.
|
||||
*/
|
||||
@@ -97,5 +116,89 @@ public class ModelFile {
|
||||
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("sourceURI");
|
||||
|
||||
// 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 ModelFile
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ModelFile.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelFile is not found in the empty JSON string", ModelFile.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 (!ModelFile.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelFile` 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 (!ModelFile.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ModelFile' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ModelFile> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ModelFile.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ModelFile>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ModelFile value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelFile read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ModelFile given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ModelFile
|
||||
* @throws IOException if the JSON string is invalid with respect to ModelFile
|
||||
*/
|
||||
public static ModelFile fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ModelFile.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ModelFile to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* ModelList
|
||||
*/
|
||||
@@ -96,5 +115,89 @@ public class ModelList {
|
||||
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("123-list");
|
||||
|
||||
// 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 ModelList
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ModelList.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelList is not found in the empty JSON string", ModelList.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 (!ModelList.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelList` 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 (!ModelList.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ModelList' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ModelList> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ModelList.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ModelList>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ModelList value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelList read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ModelList given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ModelList
|
||||
* @throws IOException if the JSON string is invalid with respect to ModelList
|
||||
*/
|
||||
public static ModelList fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ModelList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ModelList to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Model for testing reserved words
|
||||
*/
|
||||
@@ -97,5 +116,89 @@ public class ModelReturn {
|
||||
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("return");
|
||||
|
||||
// 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 ModelReturn
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ModelReturn.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelReturn is not found in the empty JSON string", ModelReturn.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 (!ModelReturn.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelReturn` 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 (!ModelReturn.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ModelReturn' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ModelReturn> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ModelReturn.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ModelReturn>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ModelReturn value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelReturn read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ModelReturn given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ModelReturn
|
||||
* @throws IOException if the JSON string is invalid with respect to ModelReturn
|
||||
*/
|
||||
public static ModelReturn fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ModelReturn.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ModelReturn to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Model for testing model name same as property name
|
||||
*/
|
||||
@@ -176,5 +195,100 @@ public class Name {
|
||||
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("name");
|
||||
openapiFields.add("snake_case");
|
||||
openapiFields.add("property");
|
||||
openapiFields.add("123Number");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("name");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Name
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Name.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Name is not found in the empty JSON string", Name.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 (!Name.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Name` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Name.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!Name.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Name' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Name> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Name.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Name>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Name value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Name read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Name given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Name
|
||||
* @throws IOException if the JSON string is invalid with respect to Name
|
||||
*/
|
||||
public static Name fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Name.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Name to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,25 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* NumberOnly
|
||||
*/
|
||||
@@ -97,5 +116,89 @@ public class NumberOnly {
|
||||
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("JustNumber");
|
||||
|
||||
// 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 NumberOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (NumberOnly.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in NumberOnly is not found in the empty JSON string", NumberOnly.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 (!NumberOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberOnly` 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 (!NumberOnly.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'NumberOnly' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<NumberOnly> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(NumberOnly.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<NumberOnly>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, NumberOnly value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NumberOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of NumberOnly given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of NumberOnly
|
||||
* @throws IOException if the JSON string is invalid with respect to NumberOnly
|
||||
*/
|
||||
public static NumberOnly fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, NumberOnly.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of NumberOnly to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,25 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Order
|
||||
*/
|
||||
@@ -291,5 +310,94 @@ public class Order {
|
||||
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("id");
|
||||
openapiFields.add("petId");
|
||||
openapiFields.add("quantity");
|
||||
openapiFields.add("shipDate");
|
||||
openapiFields.add("status");
|
||||
openapiFields.add("complete");
|
||||
|
||||
// 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 Order
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Order.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Order is not found in the empty JSON string", Order.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 (!Order.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Order` 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 (!Order.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Order' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Order> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Order.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Order>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Order value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Order given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Order
|
||||
* @throws IOException if the JSON string is invalid with respect to Order
|
||||
*/
|
||||
public static Order fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Order.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Order to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,25 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* OuterComposite
|
||||
*/
|
||||
@@ -155,5 +174,91 @@ public class OuterComposite {
|
||||
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("my_number");
|
||||
openapiFields.add("my_string");
|
||||
openapiFields.add("my_boolean");
|
||||
|
||||
// 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 OuterComposite
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (OuterComposite.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in OuterComposite is not found in the empty JSON string", OuterComposite.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 (!OuterComposite.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OuterComposite` 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 (!OuterComposite.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'OuterComposite' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<OuterComposite> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(OuterComposite.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<OuterComposite>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, OuterComposite value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OuterComposite read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of OuterComposite given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of OuterComposite
|
||||
* @throws IOException if the JSON string is invalid with respect to OuterComposite
|
||||
*/
|
||||
public static OuterComposite fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, OuterComposite.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of OuterComposite to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,25 @@ import java.util.Set;
|
||||
import org.openapitools.client.model.Category;
|
||||
import org.openapitools.client.model.Tag;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Pet
|
||||
*/
|
||||
@@ -309,5 +328,114 @@ public class Pet {
|
||||
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("id");
|
||||
openapiFields.add("category");
|
||||
openapiFields.add("name");
|
||||
openapiFields.add("photoUrls");
|
||||
openapiFields.add("tags");
|
||||
openapiFields.add("status");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("name");
|
||||
openapiRequiredFields.add("photoUrls");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Pet
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Pet.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Pet is not found in the empty JSON string", Pet.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 (!Pet.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Pet.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
// validate the optional field `category`
|
||||
if (jsonObj.getAsJsonObject("category") != null) {
|
||||
Category.validateJsonObject(jsonObj.getAsJsonObject("category"));
|
||||
}
|
||||
JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags");
|
||||
// validate the optional field `tags` (array)
|
||||
if (jsonArraytags != null) {
|
||||
for (int i = 0; i < jsonArraytags.size(); i++) {
|
||||
Tag.validateJsonObject(jsonArraytags.get(i).getAsJsonObject());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!Pet.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Pet' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Pet> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Pet.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Pet>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Pet value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pet read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Pet given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Pet
|
||||
* @throws IOException if the JSON string is invalid with respect to Pet
|
||||
*/
|
||||
public static Pet fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Pet.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Pet to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* ReadOnlyFirst
|
||||
*/
|
||||
@@ -124,5 +143,90 @@ public class ReadOnlyFirst {
|
||||
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("bar");
|
||||
openapiFields.add("baz");
|
||||
|
||||
// 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 ReadOnlyFirst
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ReadOnlyFirst.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ReadOnlyFirst is not found in the empty JSON string", ReadOnlyFirst.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 (!ReadOnlyFirst.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ReadOnlyFirst` 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 (!ReadOnlyFirst.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'ReadOnlyFirst' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<ReadOnlyFirst> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(ReadOnlyFirst.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<ReadOnlyFirst>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, ReadOnlyFirst value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadOnlyFirst read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of ReadOnlyFirst given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of ReadOnlyFirst
|
||||
* @throws IOException if the JSON string is invalid with respect to ReadOnlyFirst
|
||||
*/
|
||||
public static ReadOnlyFirst fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, ReadOnlyFirst.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of ReadOnlyFirst to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* SpecialModelName
|
||||
*/
|
||||
@@ -96,5 +115,89 @@ public class SpecialModelName {
|
||||
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("$special[property.name]");
|
||||
|
||||
// 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 SpecialModelName
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (SpecialModelName.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in SpecialModelName is not found in the empty JSON string", SpecialModelName.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 (!SpecialModelName.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialModelName` 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 (!SpecialModelName.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'SpecialModelName' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<SpecialModelName> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(SpecialModelName.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<SpecialModelName>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, SpecialModelName value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpecialModelName read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of SpecialModelName given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of SpecialModelName
|
||||
* @throws IOException if the JSON string is invalid with respect to SpecialModelName
|
||||
*/
|
||||
public static SpecialModelName fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, SpecialModelName.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of SpecialModelName to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* Tag
|
||||
*/
|
||||
@@ -125,5 +144,90 @@ public class Tag {
|
||||
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("id");
|
||||
openapiFields.add("name");
|
||||
|
||||
// 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 Tag
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Tag.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Tag is not found in the empty JSON string", Tag.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 (!Tag.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` 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 (!Tag.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'Tag' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<Tag> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(Tag.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<Tag>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, Tag value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tag read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of Tag given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of Tag
|
||||
* @throws IOException if the JSON string is invalid with respect to Tag
|
||||
*/
|
||||
public static Tag fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, Tag.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of Tag to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* TypeHolderDefault
|
||||
*/
|
||||
@@ -220,5 +239,105 @@ public class TypeHolderDefault {
|
||||
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("string_item");
|
||||
openapiFields.add("number_item");
|
||||
openapiFields.add("integer_item");
|
||||
openapiFields.add("bool_item");
|
||||
openapiFields.add("array_item");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("string_item");
|
||||
openapiRequiredFields.add("number_item");
|
||||
openapiRequiredFields.add("integer_item");
|
||||
openapiRequiredFields.add("bool_item");
|
||||
openapiRequiredFields.add("array_item");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 TypeHolderDefault
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (TypeHolderDefault.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in TypeHolderDefault is not found in the empty JSON string", TypeHolderDefault.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 (!TypeHolderDefault.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderDefault` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : TypeHolderDefault.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!TypeHolderDefault.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'TypeHolderDefault' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<TypeHolderDefault> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(TypeHolderDefault.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<TypeHolderDefault>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, TypeHolderDefault value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHolderDefault read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of TypeHolderDefault given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of TypeHolderDefault
|
||||
* @throws IOException if the JSON string is invalid with respect to TypeHolderDefault
|
||||
*/
|
||||
public static TypeHolderDefault fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, TypeHolderDefault.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of TypeHolderDefault to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* TypeHolderExample
|
||||
*/
|
||||
@@ -249,5 +268,107 @@ public class TypeHolderExample {
|
||||
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("string_item");
|
||||
openapiFields.add("number_item");
|
||||
openapiFields.add("float_item");
|
||||
openapiFields.add("integer_item");
|
||||
openapiFields.add("bool_item");
|
||||
openapiFields.add("array_item");
|
||||
|
||||
// a set of required properties/fields (JSON key names)
|
||||
openapiRequiredFields = new HashSet<String>();
|
||||
openapiRequiredFields.add("string_item");
|
||||
openapiRequiredFields.add("number_item");
|
||||
openapiRequiredFields.add("float_item");
|
||||
openapiRequiredFields.add("integer_item");
|
||||
openapiRequiredFields.add("bool_item");
|
||||
openapiRequiredFields.add("array_item");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 TypeHolderExample
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (TypeHolderExample.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in TypeHolderExample is not found in the empty JSON string", TypeHolderExample.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 (!TypeHolderExample.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderExample` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : TypeHolderExample.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
if (!TypeHolderExample.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'TypeHolderExample' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<TypeHolderExample> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(TypeHolderExample.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<TypeHolderExample>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, TypeHolderExample value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHolderExample read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of TypeHolderExample given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of TypeHolderExample
|
||||
* @throws IOException if the JSON string is invalid with respect to TypeHolderExample
|
||||
*/
|
||||
public static TypeHolderExample fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, TypeHolderExample.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of TypeHolderExample to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,25 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
@@ -299,5 +318,96 @@ public class User {
|
||||
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("id");
|
||||
openapiFields.add("username");
|
||||
openapiFields.add("firstName");
|
||||
openapiFields.add("lastName");
|
||||
openapiFields.add("email");
|
||||
openapiFields.add("password");
|
||||
openapiFields.add("phone");
|
||||
openapiFields.add("userStatus");
|
||||
|
||||
// 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 User
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (User.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in User is not found in the empty JSON string", User.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 (!User.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `User` 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 (!User.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'User' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<User> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(User.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<User>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, User value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of User given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of User
|
||||
* @throws IOException if the JSON string is invalid with respect to User
|
||||
*/
|
||||
public static User fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, User.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of User to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,25 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
/**
|
||||
* XmlItem
|
||||
*/
|
||||
@@ -983,5 +1002,117 @@ public class XmlItem {
|
||||
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("attribute_string");
|
||||
openapiFields.add("attribute_number");
|
||||
openapiFields.add("attribute_integer");
|
||||
openapiFields.add("attribute_boolean");
|
||||
openapiFields.add("wrapped_array");
|
||||
openapiFields.add("name_string");
|
||||
openapiFields.add("name_number");
|
||||
openapiFields.add("name_integer");
|
||||
openapiFields.add("name_boolean");
|
||||
openapiFields.add("name_array");
|
||||
openapiFields.add("name_wrapped_array");
|
||||
openapiFields.add("prefix_string");
|
||||
openapiFields.add("prefix_number");
|
||||
openapiFields.add("prefix_integer");
|
||||
openapiFields.add("prefix_boolean");
|
||||
openapiFields.add("prefix_array");
|
||||
openapiFields.add("prefix_wrapped_array");
|
||||
openapiFields.add("namespace_string");
|
||||
openapiFields.add("namespace_number");
|
||||
openapiFields.add("namespace_integer");
|
||||
openapiFields.add("namespace_boolean");
|
||||
openapiFields.add("namespace_array");
|
||||
openapiFields.add("namespace_wrapped_array");
|
||||
openapiFields.add("prefix_ns_string");
|
||||
openapiFields.add("prefix_ns_number");
|
||||
openapiFields.add("prefix_ns_integer");
|
||||
openapiFields.add("prefix_ns_boolean");
|
||||
openapiFields.add("prefix_ns_array");
|
||||
openapiFields.add("prefix_ns_wrapped_array");
|
||||
|
||||
// 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 XmlItem
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (XmlItem.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has reuqired fields
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in XmlItem is not found in the empty JSON string", XmlItem.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 (!XmlItem.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `XmlItem` 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 (!XmlItem.class.isAssignableFrom(type.getRawType())) {
|
||||
return null; // this class only serializes 'XmlItem' and its subtypes
|
||||
}
|
||||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
||||
final TypeAdapter<XmlItem> thisAdapter
|
||||
= gson.getDelegateAdapter(this, TypeToken.get(XmlItem.class));
|
||||
|
||||
return (TypeAdapter<T>) new TypeAdapter<XmlItem>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, XmlItem value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlItem read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of XmlItem given an JSON string
|
||||
*
|
||||
* @param jsonString JSON string
|
||||
* @return An instance of XmlItem
|
||||
* @throws IOException if the JSON string is invalid with respect to XmlItem
|
||||
*/
|
||||
public static XmlItem fromJson(String jsonString) throws IOException {
|
||||
return JSON.getGson().fromJson(jsonString, XmlItem.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an instance of XmlItem to an JSON string
|
||||
*
|
||||
* @return JSON string
|
||||
*/
|
||||
public String toJson() {
|
||||
return JSON.getGson().toJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# exclude jar for gradle wrapper
|
||||
!gradle/wrapper/*.jar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# build files
|
||||
**/target
|
||||
target
|
||||
.gradle
|
||||
build
|
||||
@@ -1,14 +0,0 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# These tests are "live" tests and should not be overwritten
|
||||
src/test/java/org/openapitools/client/StringUtilTest.java
|
||||
src/test/java/org/openapitools/client/ApiClientTest.java
|
||||
src/test/java/org/openapitools/client/ConfigurationTest.java
|
||||
src/test/java/org/openapitools/client/auth/ApiKeyAuthTest.java
|
||||
src/test/java/org/openapitools/client/auth/HttpBasicAuthTest.java
|
||||
src/test/java/org/openapitools/client/auth/RetryingOAuthTest.java
|
||||
src/test/java/org/openapitools/client/model/EnumValueTest.java
|
||||
src/test/java/org/openapitools/client/model/PetTest.java
|
||||
src/test/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnlyTest.java
|
||||
src/test/java/org/openapitools/client/JSONTest.java
|
||||
src/test/java/org/openapitools/client/api/PetApiTest.java
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
.gitignore
|
||||
.travis.yml
|
||||
README.md
|
||||
api/openapi.yaml
|
||||
build.gradle
|
||||
build.sbt
|
||||
docs/AdditionalPropertiesClass.md
|
||||
docs/Animal.md
|
||||
docs/AnotherFakeApi.md
|
||||
docs/Apple.md
|
||||
docs/AppleReq.md
|
||||
docs/ArrayOfArrayOfNumberOnly.md
|
||||
docs/ArrayOfNumberOnly.md
|
||||
docs/ArrayTest.md
|
||||
docs/Banana.md
|
||||
docs/BananaReq.md
|
||||
docs/BasquePig.md
|
||||
docs/Capitalization.md
|
||||
docs/Cat.md
|
||||
docs/CatAllOf.md
|
||||
docs/Category.md
|
||||
docs/ClassModel.md
|
||||
docs/Client.md
|
||||
docs/ComplexQuadrilateral.md
|
||||
docs/DanishPig.md
|
||||
docs/DefaultApi.md
|
||||
docs/DeprecatedObject.md
|
||||
docs/Dog.md
|
||||
docs/DogAllOf.md
|
||||
docs/Drawing.md
|
||||
docs/EnumArrays.md
|
||||
docs/EnumClass.md
|
||||
docs/EnumTest.md
|
||||
docs/EquilateralTriangle.md
|
||||
docs/FakeApi.md
|
||||
docs/FakeClassnameTags123Api.md
|
||||
docs/Foo.md
|
||||
docs/FormatTest.md
|
||||
docs/Fruit.md
|
||||
docs/FruitReq.md
|
||||
docs/GmFruit.md
|
||||
docs/GrandparentAnimal.md
|
||||
docs/HasOnlyReadOnly.md
|
||||
docs/HealthCheckResult.md
|
||||
docs/InlineResponseDefault.md
|
||||
docs/IsoscelesTriangle.md
|
||||
docs/Mammal.md
|
||||
docs/MapTest.md
|
||||
docs/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
docs/Model200Response.md
|
||||
docs/ModelApiResponse.md
|
||||
docs/ModelFile.md
|
||||
docs/ModelList.md
|
||||
docs/ModelReturn.md
|
||||
docs/Name.md
|
||||
docs/NullableClass.md
|
||||
docs/NullableShape.md
|
||||
docs/NumberOnly.md
|
||||
docs/ObjectWithDeprecatedFields.md
|
||||
docs/Order.md
|
||||
docs/OuterComposite.md
|
||||
docs/OuterEnum.md
|
||||
docs/OuterEnumDefaultValue.md
|
||||
docs/OuterEnumInteger.md
|
||||
docs/OuterEnumIntegerDefaultValue.md
|
||||
docs/ParentPet.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/PetWithRequiredTags.md
|
||||
docs/Pig.md
|
||||
docs/Quadrilateral.md
|
||||
docs/QuadrilateralInterface.md
|
||||
docs/ReadOnlyFirst.md
|
||||
docs/ScaleneTriangle.md
|
||||
docs/Shape.md
|
||||
docs/ShapeInterface.md
|
||||
docs/ShapeOrNull.md
|
||||
docs/SimpleQuadrilateral.md
|
||||
docs/SpecialModelName.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
docs/Triangle.md
|
||||
docs/TriangleInterface.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
docs/Whale.md
|
||||
docs/Zebra.md
|
||||
git_push.sh
|
||||
gradle.properties
|
||||
gradle/wrapper/gradle-wrapper.jar
|
||||
gradle/wrapper/gradle-wrapper.properties
|
||||
gradlew
|
||||
gradlew.bat
|
||||
pom.xml
|
||||
settings.gradle
|
||||
src/main/AndroidManifest.xml
|
||||
src/main/java/org/openapitools/client/ApiCallback.java
|
||||
src/main/java/org/openapitools/client/ApiClient.java
|
||||
src/main/java/org/openapitools/client/ApiException.java
|
||||
src/main/java/org/openapitools/client/ApiResponse.java
|
||||
src/main/java/org/openapitools/client/Configuration.java
|
||||
src/main/java/org/openapitools/client/GzipRequestInterceptor.java
|
||||
src/main/java/org/openapitools/client/JSON.java
|
||||
src/main/java/org/openapitools/client/Pair.java
|
||||
src/main/java/org/openapitools/client/ProgressRequestBody.java
|
||||
src/main/java/org/openapitools/client/ProgressResponseBody.java
|
||||
src/main/java/org/openapitools/client/ServerConfiguration.java
|
||||
src/main/java/org/openapitools/client/ServerVariable.java
|
||||
src/main/java/org/openapitools/client/StringUtil.java
|
||||
src/main/java/org/openapitools/client/api/AnotherFakeApi.java
|
||||
src/main/java/org/openapitools/client/api/DefaultApi.java
|
||||
src/main/java/org/openapitools/client/api/FakeApi.java
|
||||
src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java
|
||||
src/main/java/org/openapitools/client/api/PetApi.java
|
||||
src/main/java/org/openapitools/client/api/StoreApi.java
|
||||
src/main/java/org/openapitools/client/api/UserApi.java
|
||||
src/main/java/org/openapitools/client/auth/ApiKeyAuth.java
|
||||
src/main/java/org/openapitools/client/auth/Authentication.java
|
||||
src/main/java/org/openapitools/client/auth/HttpBasicAuth.java
|
||||
src/main/java/org/openapitools/client/auth/HttpBearerAuth.java
|
||||
src/main/java/org/openapitools/client/auth/OAuth.java
|
||||
src/main/java/org/openapitools/client/auth/OAuthFlow.java
|
||||
src/main/java/org/openapitools/client/auth/OAuthOkHttpClient.java
|
||||
src/main/java/org/openapitools/client/auth/RetryingOAuth.java
|
||||
src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java
|
||||
src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
|
||||
src/main/java/org/openapitools/client/model/Animal.java
|
||||
src/main/java/org/openapitools/client/model/Apple.java
|
||||
src/main/java/org/openapitools/client/model/AppleReq.java
|
||||
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/Banana.java
|
||||
src/main/java/org/openapitools/client/model/BananaReq.java
|
||||
src/main/java/org/openapitools/client/model/BasquePig.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/ComplexQuadrilateral.java
|
||||
src/main/java/org/openapitools/client/model/DanishPig.java
|
||||
src/main/java/org/openapitools/client/model/DeprecatedObject.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/Drawing.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
|
||||
src/main/java/org/openapitools/client/model/EquilateralTriangle.java
|
||||
src/main/java/org/openapitools/client/model/Foo.java
|
||||
src/main/java/org/openapitools/client/model/FormatTest.java
|
||||
src/main/java/org/openapitools/client/model/Fruit.java
|
||||
src/main/java/org/openapitools/client/model/FruitReq.java
|
||||
src/main/java/org/openapitools/client/model/GmFruit.java
|
||||
src/main/java/org/openapitools/client/model/GrandparentAnimal.java
|
||||
src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java
|
||||
src/main/java/org/openapitools/client/model/HealthCheckResult.java
|
||||
src/main/java/org/openapitools/client/model/InlineResponseDefault.java
|
||||
src/main/java/org/openapitools/client/model/IsoscelesTriangle.java
|
||||
src/main/java/org/openapitools/client/model/Mammal.java
|
||||
src/main/java/org/openapitools/client/model/MapTest.java
|
||||
src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
|
||||
src/main/java/org/openapitools/client/model/Model200Response.java
|
||||
src/main/java/org/openapitools/client/model/ModelApiResponse.java
|
||||
src/main/java/org/openapitools/client/model/ModelFile.java
|
||||
src/main/java/org/openapitools/client/model/ModelList.java
|
||||
src/main/java/org/openapitools/client/model/ModelReturn.java
|
||||
src/main/java/org/openapitools/client/model/Name.java
|
||||
src/main/java/org/openapitools/client/model/NullableClass.java
|
||||
src/main/java/org/openapitools/client/model/NullableShape.java
|
||||
src/main/java/org/openapitools/client/model/NumberOnly.java
|
||||
src/main/java/org/openapitools/client/model/ObjectWithDeprecatedFields.java
|
||||
src/main/java/org/openapitools/client/model/Order.java
|
||||
src/main/java/org/openapitools/client/model/OuterComposite.java
|
||||
src/main/java/org/openapitools/client/model/OuterEnum.java
|
||||
src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java
|
||||
src/main/java/org/openapitools/client/model/OuterEnumInteger.java
|
||||
src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java
|
||||
src/main/java/org/openapitools/client/model/ParentPet.java
|
||||
src/main/java/org/openapitools/client/model/Pet.java
|
||||
src/main/java/org/openapitools/client/model/PetWithRequiredTags.java
|
||||
src/main/java/org/openapitools/client/model/Pig.java
|
||||
src/main/java/org/openapitools/client/model/Quadrilateral.java
|
||||
src/main/java/org/openapitools/client/model/QuadrilateralInterface.java
|
||||
src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
|
||||
src/main/java/org/openapitools/client/model/ScaleneTriangle.java
|
||||
src/main/java/org/openapitools/client/model/Shape.java
|
||||
src/main/java/org/openapitools/client/model/ShapeInterface.java
|
||||
src/main/java/org/openapitools/client/model/ShapeOrNull.java
|
||||
src/main/java/org/openapitools/client/model/SimpleQuadrilateral.java
|
||||
src/main/java/org/openapitools/client/model/SpecialModelName.java
|
||||
src/main/java/org/openapitools/client/model/Tag.java
|
||||
src/main/java/org/openapitools/client/model/Triangle.java
|
||||
src/main/java/org/openapitools/client/model/TriangleInterface.java
|
||||
src/main/java/org/openapitools/client/model/User.java
|
||||
src/main/java/org/openapitools/client/model/Whale.java
|
||||
src/main/java/org/openapitools/client/model/Zebra.java
|
||||
@@ -1 +0,0 @@
|
||||
6.0.0-SNAPSHOT
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# Generated by OpenAPI Generator: https://openapi-generator.tech
|
||||
#
|
||||
# Ref: https://docs.travis-ci.com/user/languages/java/
|
||||
#
|
||||
language: java
|
||||
jdk:
|
||||
- openjdk12
|
||||
- openjdk11
|
||||
- openjdk10
|
||||
- openjdk9
|
||||
- openjdk8
|
||||
before_install:
|
||||
# ensure gradlew has proper permission
|
||||
- chmod a+x ./gradlew
|
||||
script:
|
||||
# test using maven
|
||||
#- mvn test
|
||||
# test using gradle
|
||||
- gradle test
|
||||
# test using sbt
|
||||
# - sbt test
|
||||
@@ -1,278 +0,0 @@
|
||||
# petstore-okhttp-gson-nextgen
|
||||
|
||||
OpenAPI Petstore
|
||||
- API version: 1.0.0
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
|
||||
*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
|
||||
|
||||
|
||||
## Requirements
|
||||
|
||||
Building the API client library requires:
|
||||
1. Java 1.7+
|
||||
2. Maven (3.8.3+)/Gradle (7.2+)
|
||||
|
||||
## Installation
|
||||
|
||||
To install the API client library to your local Maven repository, simply execute:
|
||||
|
||||
```shell
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
|
||||
|
||||
```shell
|
||||
mvn clean deploy
|
||||
```
|
||||
|
||||
Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
|
||||
|
||||
### Maven users
|
||||
|
||||
Add this dependency to your project's POM:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>petstore-okhttp-gson-nextgen</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Gradle users
|
||||
|
||||
Add this dependency to your project's build file:
|
||||
|
||||
```groovy
|
||||
repositories {
|
||||
mavenCentral() // Needed if the 'petstore-okhttp-gson-nextgen' jar has been published to maven central.
|
||||
mavenLocal() // Needed if the 'petstore-okhttp-gson-nextgen' jar has been published to the local maven repo.
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.openapitools:petstore-okhttp-gson-nextgen:1.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
### Others
|
||||
|
||||
At first generate the JAR by executing:
|
||||
|
||||
```shell
|
||||
mvn clean package
|
||||
```
|
||||
|
||||
Then manually install the following JARs:
|
||||
|
||||
* `target/petstore-okhttp-gson-nextgen-1.0.0.jar`
|
||||
* `target/lib/*.jar`
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation](#installation) instruction and execute the following Java code:
|
||||
|
||||
```java
|
||||
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.AnotherFakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient);
|
||||
Client client = new Client(); // Client | client model
|
||||
try {
|
||||
Client result = apiInstance.call123testSpecialTags(client);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
System.err.println("Exception when calling AnotherFakeApi#call123testSpecialTags");
|
||||
System.err.println("Status code: " + e.getCode());
|
||||
System.err.println("Reason: " + e.getResponseBody());
|
||||
System.err.println("Response headers: " + e.getResponseHeaders());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | [**call123testSpecialTags**](docs/AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*DefaultApi* | [**fooGet**](docs/DefaultApi.md#fooGet) | **GET** /foo |
|
||||
*FakeApi* | [**fakeHealthGet**](docs/FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
|
||||
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
|
||||
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
|
||||
*FakeApi* | [**fakeOuterNumberSerialize**](docs/FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
|
||||
*FakeApi* | [**fakeOuterStringSerialize**](docs/FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
|
||||
*FakeApi* | [**getArrayOfEnums**](docs/FakeApi.md#getArrayOfEnums) | **GET** /fake/array-of-enums | Array of Enums
|
||||
*FakeApi* | [**testBodyWithQueryParams**](docs/FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params |
|
||||
*FakeApi* | [**testClientModel**](docs/FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model
|
||||
*FakeApi* | [**testEndpointParameters**](docs/FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | [**testEnumParameters**](docs/FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
|
||||
*FakeApi* | [**testGroupParameters**](docs/FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*FakeApi* | [**testInlineAdditionalProperties**](docs/FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeApi* | [**testJsonFormData**](docs/FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters |
|
||||
*FakeClassnameTags123Api* | [**testClassname**](docs/FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
|
||||
*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*PetApi* | [**uploadFileWithRequiredFile**](docs/PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
|
||||
*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user
|
||||
*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user
|
||||
*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name
|
||||
*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system
|
||||
*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation for Models
|
||||
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [Apple](docs/Apple.md)
|
||||
- [AppleReq](docs/AppleReq.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Banana](docs/Banana.md)
|
||||
- [BananaReq](docs/BananaReq.md)
|
||||
- [BasquePig](docs/BasquePig.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)
|
||||
- [ComplexQuadrilateral](docs/ComplexQuadrilateral.md)
|
||||
- [DanishPig](docs/DanishPig.md)
|
||||
- [DeprecatedObject](docs/DeprecatedObject.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
- [DogAllOf](docs/DogAllOf.md)
|
||||
- [Drawing](docs/Drawing.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
- [EquilateralTriangle](docs/EquilateralTriangle.md)
|
||||
- [Foo](docs/Foo.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
- [Fruit](docs/Fruit.md)
|
||||
- [FruitReq](docs/FruitReq.md)
|
||||
- [GmFruit](docs/GmFruit.md)
|
||||
- [GrandparentAnimal](docs/GrandparentAnimal.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||
- [InlineResponseDefault](docs/InlineResponseDefault.md)
|
||||
- [IsoscelesTriangle](docs/IsoscelesTriangle.md)
|
||||
- [Mammal](docs/Mammal.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [ModelApiResponse](docs/ModelApiResponse.md)
|
||||
- [ModelFile](docs/ModelFile.md)
|
||||
- [ModelList](docs/ModelList.md)
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NullableClass](docs/NullableClass.md)
|
||||
- [NullableShape](docs/NullableShape.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [ObjectWithDeprecatedFields](docs/ObjectWithDeprecatedFields.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [OuterComposite](docs/OuterComposite.md)
|
||||
- [OuterEnum](docs/OuterEnum.md)
|
||||
- [OuterEnumDefaultValue](docs/OuterEnumDefaultValue.md)
|
||||
- [OuterEnumInteger](docs/OuterEnumInteger.md)
|
||||
- [OuterEnumIntegerDefaultValue](docs/OuterEnumIntegerDefaultValue.md)
|
||||
- [ParentPet](docs/ParentPet.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [PetWithRequiredTags](docs/PetWithRequiredTags.md)
|
||||
- [Pig](docs/Pig.md)
|
||||
- [Quadrilateral](docs/Quadrilateral.md)
|
||||
- [QuadrilateralInterface](docs/QuadrilateralInterface.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [ScaleneTriangle](docs/ScaleneTriangle.md)
|
||||
- [Shape](docs/Shape.md)
|
||||
- [ShapeInterface](docs/ShapeInterface.md)
|
||||
- [ShapeOrNull](docs/ShapeOrNull.md)
|
||||
- [SimpleQuadrilateral](docs/SimpleQuadrilateral.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [Triangle](docs/Triangle.md)
|
||||
- [TriangleInterface](docs/TriangleInterface.md)
|
||||
- [User](docs/User.md)
|
||||
- [Whale](docs/Whale.md)
|
||||
- [Zebra](docs/Zebra.md)
|
||||
|
||||
|
||||
## Documentation for Authorization
|
||||
|
||||
Authentication schemes defined for the API:
|
||||
### api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
### api_key_query
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key_query
|
||||
- **Location**: URL query string
|
||||
|
||||
### bearer_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
### http_basic_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
### http_signature_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
### petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- write:pets: modify pets in your account
|
||||
- read:pets: read your pets
|
||||
|
||||
|
||||
## Recommendation
|
||||
|
||||
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,153 +0,0 @@
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'com.diffplug.spotless'
|
||||
|
||||
group = 'org.openapitools'
|
||||
version = '1.0.0'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.+'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||
classpath 'com.diffplug.spotless:spotless-plugin-gradle:5.17.1'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
sourceSets {
|
||||
main.java.srcDirs = ['src/main/java']
|
||||
}
|
||||
|
||||
if(hasProperty('target') && target == 'android') {
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.github.dcendents.android-maven'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion '25.0.2'
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 25
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
// Rename the aar correctly
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.aar')) {
|
||||
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
android.libraryVariants.all { variant ->
|
||||
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
|
||||
task.description = "Create jar artifact for ${variant.name}"
|
||||
task.dependsOn variant.javaCompile
|
||||
task.from variant.javaCompile.destinationDir
|
||||
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
|
||||
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
|
||||
artifacts.add('archives', task);
|
||||
}
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
artifactId = 'petstore-okhttp-gson-nextgen'
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task execute(type:JavaExec) {
|
||||
main = System.getProperty('mainClass')
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
jakarta_annotation_version = "1.3.5"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'io.swagger:swagger-annotations:1.5.24'
|
||||
implementation "com.google.code.findbugs:jsr305:3.0.2"
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'io.gsonfire:gson-fire:1.8.4'
|
||||
implementation 'org.openapitools:jackson-databind-nullable:0.2.1'
|
||||
implementation group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.1'
|
||||
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
|
||||
implementation 'org.threeten:threetenbp:1.4.3'
|
||||
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation 'org.mockito:mockito-core:3.11.2'
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.tags = [ "http.response.details:a:Http Response Details" ]
|
||||
}
|
||||
|
||||
// Use spotless plugin to automatically format code, remove unused import, etc
|
||||
// To apply changes directly to the file, run `gradlew spotlessApply`
|
||||
// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle
|
||||
spotless {
|
||||
// comment out below to run spotless as part of the `check` task
|
||||
enforceCheck false
|
||||
|
||||
format 'misc', {
|
||||
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
|
||||
target '.gitignore'
|
||||
|
||||
// define the steps to apply to those files
|
||||
trimTrailingWhitespace()
|
||||
indentWithSpaces() // Takes an integer argument if you don't like 4
|
||||
endWithNewline()
|
||||
}
|
||||
java {
|
||||
// don't need to set target, it is inferred from java
|
||||
|
||||
// apply a specific flavor of google-java-format
|
||||
googleJavaFormat('1.8').aosp().reflowLongStrings()
|
||||
|
||||
removeUnusedImports()
|
||||
importOrder()
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
lazy val root = (project in file(".")).
|
||||
settings(
|
||||
organization := "org.openapitools",
|
||||
name := "petstore-okhttp-gson-nextgen",
|
||||
version := "1.0.0",
|
||||
scalaVersion := "2.11.4",
|
||||
scalacOptions ++= Seq("-feature"),
|
||||
javacOptions in compile ++= Seq("-Xlint:deprecation"),
|
||||
publishArtifact in (Compile, packageDoc) := false,
|
||||
resolvers += Resolver.mavenLocal,
|
||||
libraryDependencies ++= Seq(
|
||||
"io.swagger" % "swagger-annotations" % "1.5.24",
|
||||
"com.squareup.okhttp3" % "okhttp" % "4.9.1",
|
||||
"com.squareup.okhttp3" % "logging-interceptor" % "4.9.1",
|
||||
"com.google.code.gson" % "gson" % "2.8.6",
|
||||
"org.apache.commons" % "commons-lang3" % "3.10",
|
||||
"org.openapitools" % "jackson-databind-nullable" % "0.2.2",
|
||||
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1",
|
||||
"org.threeten" % "threetenbp" % "1.4.3" % "compile",
|
||||
"io.gsonfire" % "gson-fire" % "1.8.3" % "compile",
|
||||
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
|
||||
"com.google.code.findbugs" % "jsr305" % "3.0.2" % "compile",
|
||||
"jakarta.annotation" % "jakarta.annotation-api" % "1.3.5" % "compile",
|
||||
"junit" % "junit" % "4.13.1" % "test",
|
||||
"com.novocode" % "junit-interface" % "0.10" % "test"
|
||||
)
|
||||
)
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesAnyType
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesArray
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesBoolean
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesClass
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**mapProperty** | **Map<String, String>** | | [optional]
|
||||
**mapOfMapProperty** | **Map<String, Map<String, String>>** | | [optional]
|
||||
**anytype1** | **Object** | | [optional]
|
||||
**mapWithUndeclaredPropertiesAnytype1** | **Object** | | [optional]
|
||||
**mapWithUndeclaredPropertiesAnytype2** | **Object** | | [optional]
|
||||
**mapWithUndeclaredPropertiesAnytype3** | **Map<String, Object>** | | [optional]
|
||||
**emptyMap** | **Object** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional]
|
||||
**mapWithUndeclaredPropertiesString** | **Map<String, String>** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesInteger
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesNumber
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesObject
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# AdditionalPropertiesString
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
# Animal
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**className** | **String** | |
|
||||
**color** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
# AnimalFarm
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# AnotherFakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**call123testSpecialTags**](AnotherFakeApi.md#call123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
|
||||
|
||||
<a name="call123testSpecialTags"></a>
|
||||
# **call123testSpecialTags**
|
||||
> Client call123testSpecialTags(client)
|
||||
|
||||
To test special tags
|
||||
|
||||
To test special tags and operation ID starting with number
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.AnotherFakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient);
|
||||
Client client = new Client(); // Client | client model
|
||||
try {
|
||||
Client result = apiInstance.call123testSpecialTags(client);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**client** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | successful operation | - |
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# ArrayOfArrayOfNumberOnly
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayArrayNumber** | **List<List<BigDecimal>>** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# ArrayOfNumberOnly
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayNumber** | **List<BigDecimal>** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
|
||||
# ArrayTest
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayOfString** | **List<String>** | | [optional]
|
||||
**arrayArrayOfInteger** | **List<List<Long>>** | | [optional]
|
||||
**arrayArrayOfModel** | **List<List<ReadOnlyFirst>>** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
|
||||
# BigCat
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**kind** | [**KindEnum**](#KindEnum) | | [optional]
|
||||
|
||||
|
||||
|
||||
## Enum: KindEnum
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
LIONS | "lions"
|
||||
TIGERS | "tigers"
|
||||
LEOPARDS | "leopards"
|
||||
JAGUARS | "jaguars"
|
||||
|
||||
|
||||
|
||||
@@ -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,18 +0,0 @@
|
||||
|
||||
|
||||
# Capitalization
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**smallCamel** | **String** | | [optional]
|
||||
**capitalCamel** | **String** | | [optional]
|
||||
**smallSnake** | **String** | | [optional]
|
||||
**capitalSnake** | **String** | | [optional]
|
||||
**scAETHFlowPoints** | **String** | | [optional]
|
||||
**ATT_NAME** | **String** | Name of the pet | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# Cat
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **Boolean** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# CatAllOf
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **Boolean** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
# Category
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **Long** | | [optional]
|
||||
**name** | **String** | |
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
# ClassModel
|
||||
|
||||
Model for testing model with \"_class\" property
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**propertyClass** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# Client
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**client** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# Dog
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**breed** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
# DogAllOf
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**breed** | **String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
|
||||
# EnumArrays
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**justSymbol** | [**JustSymbolEnum**](#JustSymbolEnum) | | [optional]
|
||||
**arrayEnum** | [**List<ArrayEnumEnum>**](#List<ArrayEnumEnum>) | | [optional]
|
||||
|
||||
|
||||
|
||||
## Enum: JustSymbolEnum
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
GREATER_THAN_OR_EQUAL_TO | ">="
|
||||
DOLLAR | "$"
|
||||
|
||||
|
||||
|
||||
## Enum: List<ArrayEnumEnum>
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
FISH | "fish"
|
||||
CRAB | "crab"
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
|
||||
# EnumClass
|
||||
|
||||
## Enum
|
||||
|
||||
|
||||
* `_ABC` (value: `"_abc"`)
|
||||
|
||||
* `_EFG` (value: `"-efg"`)
|
||||
|
||||
* `_XYZ_` (value: `"(xyz)"`)
|
||||
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
|
||||
|
||||
# EnumTest
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**enumString** | [**EnumStringEnum**](#EnumStringEnum) | | [optional]
|
||||
**enumStringRequired** | [**EnumStringRequiredEnum**](#EnumStringRequiredEnum) | |
|
||||
**enumInteger** | [**EnumIntegerEnum**](#EnumIntegerEnum) | | [optional]
|
||||
**enumIntegerOnly** | [**EnumIntegerOnlyEnum**](#EnumIntegerOnlyEnum) | | [optional]
|
||||
**enumNumber** | [**EnumNumberEnum**](#EnumNumberEnum) | | [optional]
|
||||
**outerEnum** | **OuterEnum** | | [optional]
|
||||
**outerEnumInteger** | **OuterEnumInteger** | | [optional]
|
||||
**outerEnumDefaultValue** | **OuterEnumDefaultValue** | | [optional]
|
||||
**outerEnumIntegerDefaultValue** | **OuterEnumIntegerDefaultValue** | | [optional]
|
||||
|
||||
|
||||
|
||||
## Enum: EnumStringEnum
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
UPPER | "UPPER"
|
||||
LOWER | "lower"
|
||||
EMPTY | ""
|
||||
|
||||
|
||||
|
||||
## Enum: EnumStringRequiredEnum
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
UPPER | "UPPER"
|
||||
LOWER | "lower"
|
||||
EMPTY | ""
|
||||
|
||||
|
||||
|
||||
## Enum: EnumIntegerEnum
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
NUMBER_1 | 1
|
||||
NUMBER_MINUS_1 | -1
|
||||
|
||||
|
||||
|
||||
## Enum: EnumIntegerOnlyEnum
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
NUMBER_2 | 2
|
||||
NUMBER_MINUS_2 | -2
|
||||
|
||||
|
||||
|
||||
## Enum: EnumNumberEnum
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
NUMBER_1_DOT_1 | 1.1
|
||||
NUMBER_MINUS_1_DOT_2 | -1.2
|
||||
|
||||
|
||||
|
||||
@@ -1,888 +0,0 @@
|
||||
# FakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**fakeHealthGet**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint
|
||||
[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean |
|
||||
[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite |
|
||||
[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number |
|
||||
[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string |
|
||||
[**getArrayOfEnums**](FakeApi.md#getArrayOfEnums) | **GET** /fake/array-of-enums | Array of Enums
|
||||
[**testBodyWithQueryParams**](FakeApi.md#testBodyWithQueryParams) | **PUT** /fake/body-with-query-params |
|
||||
[**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model
|
||||
[**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
[**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters
|
||||
[**testGroupParameters**](FakeApi.md#testGroupParameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
[**testInlineAdditionalProperties**](FakeApi.md#testInlineAdditionalProperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
[**testJsonFormData**](FakeApi.md#testJsonFormData) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
[**testQueryParameterCollectionFormat**](FakeApi.md#testQueryParameterCollectionFormat) | **PUT** /fake/test-query-parameters |
|
||||
|
||||
|
||||
<a name="fakeHealthGet"></a>
|
||||
# **fakeHealthGet**
|
||||
> HealthCheckResult fakeHealthGet()
|
||||
|
||||
Health check endpoint
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
try {
|
||||
HealthCheckResult result = apiInstance.fakeHealthGet();
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**HealthCheckResult**](HealthCheckResult.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | The instance started successfully | - |
|
||||
|
||||
<a name="fakeOuterBooleanSerialize"></a>
|
||||
# **fakeOuterBooleanSerialize**
|
||||
> Boolean fakeOuterBooleanSerialize(body)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer boolean types
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
Boolean body = true; // Boolean | Input boolean as post body
|
||||
try {
|
||||
Boolean result = apiInstance.fakeOuterBooleanSerialize(body);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **Boolean**| Input boolean as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**Boolean**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Output boolean | - |
|
||||
|
||||
<a name="fakeOuterCompositeSerialize"></a>
|
||||
# **fakeOuterCompositeSerialize**
|
||||
> OuterComposite fakeOuterCompositeSerialize(outerComposite)
|
||||
|
||||
|
||||
|
||||
Test serialization of object with outer number type
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
OuterComposite outerComposite = new OuterComposite(); // OuterComposite | Input composite as post body
|
||||
try {
|
||||
OuterComposite result = apiInstance.fakeOuterCompositeSerialize(outerComposite);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**outerComposite** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterComposite**](OuterComposite.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Output composite | - |
|
||||
|
||||
<a name="fakeOuterNumberSerialize"></a>
|
||||
# **fakeOuterNumberSerialize**
|
||||
> BigDecimal fakeOuterNumberSerialize(body)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer number types
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
BigDecimal body = new BigDecimal(78); // BigDecimal | Input number as post body
|
||||
try {
|
||||
BigDecimal result = apiInstance.fakeOuterNumberSerialize(body);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **BigDecimal**| Input number as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**BigDecimal**](BigDecimal.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Output number | - |
|
||||
|
||||
<a name="fakeOuterStringSerialize"></a>
|
||||
# **fakeOuterStringSerialize**
|
||||
> String fakeOuterStringSerialize(body)
|
||||
|
||||
|
||||
|
||||
Test serialization of outer string types
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
String body = "body_example"; // String | Input string as post body
|
||||
try {
|
||||
String result = apiInstance.fakeOuterStringSerialize(body);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | **String**| Input string as post body | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
**String**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: */*
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Output string | - |
|
||||
|
||||
<a name="getArrayOfEnums"></a>
|
||||
# **getArrayOfEnums**
|
||||
> List<OuterEnum> getArrayOfEnums()
|
||||
|
||||
Array of Enums
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
try {
|
||||
List<OuterEnum> result = apiInstance.getArrayOfEnums();
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**List<OuterEnum>**](OuterEnum.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Got named array of enums | - |
|
||||
|
||||
<a name="testBodyWithQueryParams"></a>
|
||||
# **testBodyWithQueryParams**
|
||||
> testBodyWithQueryParams(query, user)
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
String query = "query_example"; // String |
|
||||
User user = new User(); // User |
|
||||
try {
|
||||
apiInstance.testBodyWithQueryParams(query, user);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**query** | **String**| |
|
||||
**user** | [**User**](User.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Success | - |
|
||||
|
||||
<a name="testClientModel"></a>
|
||||
# **testClientModel**
|
||||
> Client testClientModel(client)
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
Client client = new Client(); // Client | client model
|
||||
try {
|
||||
Client result = apiInstance.testClientModel(client);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**client** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | successful operation | - |
|
||||
|
||||
<a name="testEndpointParameters"></a>
|
||||
# **testEndpointParameters**
|
||||
> testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback)
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.auth.*;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
// Configure HTTP basic authorization: http_basic_test
|
||||
HttpBasicAuth http_basic_test = (HttpBasicAuth) defaultClient.getAuthentication("http_basic_test");
|
||||
http_basic_test.setUsername("YOUR USERNAME");
|
||||
http_basic_test.setPassword("YOUR PASSWORD");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
BigDecimal number = new BigDecimal(78); // BigDecimal | None
|
||||
Double _double = 3.4D; // Double | None
|
||||
String patternWithoutDelimiter = "patternWithoutDelimiter_example"; // String | None
|
||||
byte[] _byte = null; // byte[] | None
|
||||
Integer integer = 56; // Integer | None
|
||||
Integer int32 = 56; // Integer | None
|
||||
Long int64 = 56L; // Long | None
|
||||
Float _float = 3.4F; // Float | None
|
||||
String string = "string_example"; // String | None
|
||||
File binary = new File("/path/to/file"); // File | None
|
||||
LocalDate date = LocalDate.now(); // LocalDate | None
|
||||
OffsetDateTime dateTime = OffsetDateTime.parse("OffsetDateTime.parse("2010-02-01T09:20:10.111110Z[UTC]", java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME.withZone(java.time.ZoneId.systemDefault()))"); // OffsetDateTime | None
|
||||
String password = "password_example"; // String | None
|
||||
String paramCallback = "paramCallback_example"; // String | None
|
||||
try {
|
||||
apiInstance.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**number** | **BigDecimal**| None |
|
||||
**_double** | **Double**| None |
|
||||
**patternWithoutDelimiter** | **String**| None |
|
||||
**_byte** | **byte[]**| None |
|
||||
**integer** | **Integer**| None | [optional]
|
||||
**int32** | **Integer**| None | [optional]
|
||||
**int64** | **Long**| None | [optional]
|
||||
**_float** | **Float**| None | [optional]
|
||||
**string** | **String**| None | [optional]
|
||||
**binary** | **File**| None | [optional]
|
||||
**date** | **LocalDate**| None | [optional]
|
||||
**dateTime** | **OffsetDateTime**| None | [optional] [default to OffsetDateTime.parse("2010-02-01T09:20:10.111110Z[UTC]", java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME.withZone(java.time.ZoneId.systemDefault()))]
|
||||
**password** | **String**| None | [optional]
|
||||
**paramCallback** | **String**| None | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_basic_test](../README.md#http_basic_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**400** | Invalid username supplied | - |
|
||||
**404** | User not found | - |
|
||||
|
||||
<a name="testEnumParameters"></a>
|
||||
# **testEnumParameters**
|
||||
> testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString)
|
||||
|
||||
To test enum parameters
|
||||
|
||||
To test enum parameters
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
List<String> enumHeaderStringArray = Arrays.asList("$"); // List<String> | Header parameter enum test (string array)
|
||||
String enumHeaderString = "_abc"; // String | Header parameter enum test (string)
|
||||
List<String> enumQueryStringArray = Arrays.asList("$"); // List<String> | Query parameter enum test (string array)
|
||||
String enumQueryString = "_abc"; // String | Query parameter enum test (string)
|
||||
Integer enumQueryInteger = 1; // Integer | Query parameter enum test (double)
|
||||
Double enumQueryDouble = 1.1D; // Double | Query parameter enum test (double)
|
||||
List<String> enumFormStringArray = Arrays.asList("$"); // List<String> | Form parameter enum test (string array)
|
||||
String enumFormString = "_abc"; // String | Form parameter enum test (string)
|
||||
try {
|
||||
apiInstance.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**enumHeaderStringArray** | [**List<String>**](String.md)| Header parameter enum test (string array) | [optional] [enum: >, $]
|
||||
**enumHeaderString** | **String**| Header parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)]
|
||||
**enumQueryStringArray** | [**List<String>**](String.md)| Query parameter enum test (string array) | [optional] [enum: >, $]
|
||||
**enumQueryString** | **String**| Query parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)]
|
||||
**enumQueryInteger** | **Integer**| Query parameter enum test (double) | [optional] [enum: 1, -2]
|
||||
**enumQueryDouble** | **Double**| Query parameter enum test (double) | [optional] [enum: 1.1, -1.2]
|
||||
**enumFormStringArray** | [**List<String>**](String.md)| Form parameter enum test (string array) | [optional] [enum: >, $]
|
||||
**enumFormString** | **String**| Form parameter enum test (string) | [optional] [default to -efg] [enum: _abc, -efg, (xyz)]
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**400** | Invalid request | - |
|
||||
**404** | Not found | - |
|
||||
|
||||
<a name="testGroupParameters"></a>
|
||||
# **testGroupParameters**
|
||||
> testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group).stringGroup(stringGroup).booleanGroup(booleanGroup).int64Group(int64Group).execute();
|
||||
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.auth.*;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
// Configure HTTP bearer authorization: bearer_test
|
||||
HttpBearerAuth bearer_test = (HttpBearerAuth) defaultClient.getAuthentication("bearer_test");
|
||||
bearer_test.setBearerToken("BEARER TOKEN");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
Integer requiredStringGroup = 56; // Integer | Required String in group parameters
|
||||
Boolean requiredBooleanGroup = true; // Boolean | Required Boolean in group parameters
|
||||
Long requiredInt64Group = 56L; // Long | Required Integer in group parameters
|
||||
Integer stringGroup = 56; // Integer | String in group parameters
|
||||
Boolean booleanGroup = true; // Boolean | Boolean in group parameters
|
||||
Long int64Group = 56L; // Long | Integer in group parameters
|
||||
try {
|
||||
apiInstance.testGroupParameters(requiredStringGroup, requiredBooleanGroup, requiredInt64Group)
|
||||
.stringGroup(stringGroup)
|
||||
.booleanGroup(booleanGroup)
|
||||
.int64Group(int64Group)
|
||||
.execute();
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**requiredStringGroup** | **Integer**| Required String in group parameters |
|
||||
**requiredBooleanGroup** | **Boolean**| Required Boolean in group parameters |
|
||||
**requiredInt64Group** | **Long**| Required Integer in group parameters |
|
||||
**stringGroup** | **Integer**| String in group parameters | [optional]
|
||||
**booleanGroup** | **Boolean**| Boolean in group parameters | [optional]
|
||||
**int64Group** | **Long**| Integer in group parameters | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[bearer_test](../README.md#bearer_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**400** | Someting wrong | - |
|
||||
|
||||
<a name="testInlineAdditionalProperties"></a>
|
||||
# **testInlineAdditionalProperties**
|
||||
> testInlineAdditionalProperties(requestBody)
|
||||
|
||||
test inline additionalProperties
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
Map<String, String> requestBody = new HashMap(); // Map<String, String> | request body
|
||||
try {
|
||||
apiInstance.testInlineAdditionalProperties(requestBody);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**requestBody** | [**Map<String, String>**](String.md)| request body |
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | successful operation | - |
|
||||
|
||||
<a name="testJsonFormData"></a>
|
||||
# **testJsonFormData**
|
||||
> testJsonFormData(param, param2)
|
||||
|
||||
test json serialization of form data
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
String param = "param_example"; // String | field1
|
||||
String param2 = "param2_example"; // String | field2
|
||||
try {
|
||||
apiInstance.testJsonFormData(param, param2);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**param** | **String**| field1 |
|
||||
**param2** | **String**| field2 |
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | successful operation | - |
|
||||
|
||||
<a name="testQueryParameterCollectionFormat"></a>
|
||||
# **testQueryParameterCollectionFormat**
|
||||
> testQueryParameterCollectionFormat(pipe, ioutil, http, url, context)
|
||||
|
||||
|
||||
|
||||
To test the collection format in query parameters
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeApi;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
FakeApi apiInstance = new FakeApi(defaultClient);
|
||||
List<String> pipe = Arrays.asList(); // List<String> |
|
||||
List<String> ioutil = Arrays.asList(); // List<String> |
|
||||
List<String> http = Arrays.asList(); // List<String> |
|
||||
List<String> url = Arrays.asList(); // List<String> |
|
||||
List<String> context = Arrays.asList(); // List<String> |
|
||||
try {
|
||||
apiInstance.testQueryParameterCollectionFormat(pipe, ioutil, http, url, context);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pipe** | [**List<String>**](String.md)| |
|
||||
**ioutil** | [**List<String>**](String.md)| |
|
||||
**http** | [**List<String>**](String.md)| |
|
||||
**url** | [**List<String>**](String.md)| |
|
||||
**context** | [**List<String>**](String.md)| |
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | Success | - |
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
# FakeClassnameTags123Api
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
|
||||
|
||||
<a name="testClassname"></a>
|
||||
# **testClassname**
|
||||
> Client testClassname(client)
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
### Example
|
||||
```java
|
||||
// Import classes:
|
||||
import org.openapitools.client.ApiClient;
|
||||
import org.openapitools.client.ApiException;
|
||||
import org.openapitools.client.Configuration;
|
||||
import org.openapitools.client.auth.*;
|
||||
import org.openapitools.client.models.*;
|
||||
import org.openapitools.client.api.FakeClassnameTags123Api;
|
||||
|
||||
public class Example {
|
||||
public static void main(String[] args) {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
|
||||
|
||||
// Configure API key authorization: api_key_query
|
||||
ApiKeyAuth api_key_query = (ApiKeyAuth) defaultClient.getAuthentication("api_key_query");
|
||||
api_key_query.setApiKey("YOUR API KEY");
|
||||
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||
//api_key_query.setApiKeyPrefix("Token");
|
||||
|
||||
FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api(defaultClient);
|
||||
Client client = new Client(); // Client | client model
|
||||
try {
|
||||
Client result = apiInstance.testClassname(client);
|
||||
System.out.println(result);
|
||||
} catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**client** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key_query](../README.md#api_key_query)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
### HTTP response details
|
||||
| Status code | Description | Response headers |
|
||||
|-------------|-------------|------------------|
|
||||
**200** | successful operation | - |
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
# FileSchemaTestClass
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**file** | [**java.io.File**](java.io.File.md) | | [optional]
|
||||
**files** | [**List<java.io.File>**](java.io.File.md) | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
|
||||
|
||||
# FormatTest
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**integer** | **Integer** | | [optional]
|
||||
**int32** | **Integer** | | [optional]
|
||||
**int64** | **Long** | | [optional]
|
||||
**number** | **BigDecimal** | |
|
||||
**_float** | **Float** | | [optional]
|
||||
**_double** | **Double** | | [optional]
|
||||
**decimal** | **BigDecimal** | | [optional]
|
||||
**string** | **String** | | [optional]
|
||||
**_byte** | **byte[]** | |
|
||||
**binary** | **File** | | [optional]
|
||||
**date** | **LocalDate** | |
|
||||
**dateTime** | **OffsetDateTime** | | [optional]
|
||||
**uuid** | **UUID** | | [optional]
|
||||
**password** | **String** | |
|
||||
**patternWithDigits** | **String** | A string that is a 10 digit number. Can have leading zeros. | [optional]
|
||||
**patternWithDigitsAndDelimiter** | **String** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
# HasOnlyReadOnly
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **String** | | [optional] [readonly]
|
||||
**foo** | **String** | | [optional] [readonly]
|
||||
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
|
||||
# MapTest
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**mapMapOfString** | **Map<String, Map<String, String>>** | | [optional]
|
||||
**mapOfEnumString** | [**Map<String, InnerEnum>**](#Map<String, InnerEnum>) | | [optional]
|
||||
**directMap** | **Map<String, Boolean>** | | [optional]
|
||||
**indirectMap** | **Map<String, Boolean>** | | [optional]
|
||||
|
||||
|
||||
|
||||
## Enum: Map<String, InnerEnum>
|
||||
|
||||
Name | Value
|
||||
---- | -----
|
||||
UPPER | "UPPER"
|
||||
LOWER | "lower"
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user