mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 17:56:11 +00:00
[Java][Jersey2] various improvements (#6518)
* [java][jersey2] Add support for discriminator, fix nullable typo and nullable deserialization (#6495) * Mustache template should use invokerPackage tag to generate import * fix typo, fix script issue, add log statement for troubleshooting * Add java jersey2 samples with OpenAPI doc that has HTTP signature security scheme * Add sample for Java jersey2 and HTTP signature scheme * Add unit test for oneOf schema deserialization * Add unit test for oneOf schema deserialization * Add log statements * Add profile for jersey2 * Temporarily disable unit test * Temporarily disable unit test * support for discriminator in jersey2 * fix typo in pom.xml * disable unit test because jersey2 deserialization is broken * disable unit test because jersey2 deserialization is broken * fix duplicate jersey2 samples * fix duplicate jersey2 samples * Add code comments * fix duplicate artifact id * fix duplicate jersey2 samples * run samples scripts * resolve merge conflicts * Add unit tests * fix unit tests * continue implementation of discriminator lookup * throw deserialization exception when value is null and schema does not allow null value * continue implementation of compose schema * continue implementation of compose schema * continue implementation of compose schema * Add more unit tests * Add unit tests for anyOf * Add unit tests Co-authored-by: Vikrant Balyan (vvb) <vvb@cisco.com> * update samples * add tests to oas3 java jersey2 petstore * comment out jersey2 ensure uptodate * Jersey2 supports additional properties with composed schema (#6523) * Mustache template should use invokerPackage tag to generate import * fix typo, fix script issue, add log statement for troubleshooting * Add java jersey2 samples with OpenAPI doc that has HTTP signature security scheme * Add sample for Java jersey2 and HTTP signature scheme * Add unit test for oneOf schema deserialization * Add unit test for oneOf schema deserialization * Add log statements * Add profile for jersey2 * Temporarily disable unit test * Temporarily disable unit test * support for discriminator in jersey2 * fix typo in pom.xml * disable unit test because jersey2 deserialization is broken * disable unit test because jersey2 deserialization is broken * fix duplicate jersey2 samples * fix duplicate jersey2 samples * Add code comments * fix duplicate artifact id * fix duplicate jersey2 samples * run samples scripts * resolve merge conflicts * Add unit tests * fix unit tests * continue implementation of discriminator lookup * throw deserialization exception when value is null and schema does not allow null value * continue implementation of compose schema * continue implementation of compose schema * continue implementation of compose schema * Add more unit tests * Add unit tests for anyOf * Add unit tests * Set supportsAdditionalPropertiesWithComposedSchema to true for Java jersey2 * Support additional properties as nested field * Support additional properties as nested field * add code comments * add customer deserializer * Fix 'method too big' error with generated code * resolve merge conflicts Co-authored-by: Vikrant Balyan (vvb) <vvb@cisco.com> * [Jersey2] Fix code generation of 'registerDiscriminator' method for large models (#6535) * Mustache template should use invokerPackage tag to generate import * fix typo, fix script issue, add log statement for troubleshooting * Add java jersey2 samples with OpenAPI doc that has HTTP signature security scheme * Add sample for Java jersey2 and HTTP signature scheme * Add unit test for oneOf schema deserialization * Add unit test for oneOf schema deserialization * Add log statements * Add profile for jersey2 * Temporarily disable unit test * Temporarily disable unit test * support for discriminator in jersey2 * fix typo in pom.xml * disable unit test because jersey2 deserialization is broken * disable unit test because jersey2 deserialization is broken * fix duplicate jersey2 samples * fix duplicate jersey2 samples * Add code comments * fix duplicate artifact id * fix duplicate jersey2 samples * run samples scripts * resolve merge conflicts * Add unit tests * fix unit tests * continue implementation of discriminator lookup * throw deserialization exception when value is null and schema does not allow null value * continue implementation of compose schema * continue implementation of compose schema * continue implementation of compose schema * Add more unit tests * Add unit tests for anyOf * Add unit tests * Fix 'method too big' error with generated code * resolve merge conflicts Co-authored-by: Vikrant Balyan (vvb) <vvb@cisco.com> * update samples * comment out tests * support additional properties in serialize and deserialize * add discriminator lookup * remove oneof/anyof logic in apilcient * add serializer to mammal.java * add serialize to oneOf model * add serializer to anyof model * comment out test cases that are subject to further discussion * add back files * update configs, samples Co-authored-by: Sebastien Rosset <serosset@cisco.com> Co-authored-by: Vikrant Balyan (vvb) <vvb@cisco.com>
This commit is contained in:
@@ -67,6 +67,7 @@
|
||||
<argLine>-Xms512m -Xmx1500m</argLine>
|
||||
<parallel>methods</parallel>
|
||||
<threadCount>10</threadCount>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
@@ -56,7 +56,6 @@ import org.openapitools.client.auth.HttpBearerAuth;
|
||||
import org.openapitools.client.auth.HttpSignatureAuth;
|
||||
import org.openapitools.client.auth.ApiKeyAuth;
|
||||
import org.openapitools.client.auth.OAuth;
|
||||
import org.openapitools.client.model.AbstractOpenApiSchema;
|
||||
|
||||
|
||||
public class ApiClient {
|
||||
@@ -890,67 +889,6 @@ public class ApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractOpenApiSchema deserializeSchemas(Response response, AbstractOpenApiSchema schema) throws ApiException{
|
||||
|
||||
Object result = null;
|
||||
int matchCounter = 0;
|
||||
ArrayList<String> matchSchemas = new ArrayList<>();
|
||||
|
||||
if (schema.isNullable()) {
|
||||
response.bufferEntity();
|
||||
if ("{}".equals(String.valueOf(response.readEntity(String.class))) ||
|
||||
"".equals(String.valueOf(response.readEntity(String.class)))) {
|
||||
// schema is nullable and the response body is {} or empty string
|
||||
return schema;
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, GenericType> entry : schema.getSchemas().entrySet()) {
|
||||
String schemaName = entry.getKey();
|
||||
GenericType schemaType = entry.getValue();
|
||||
|
||||
if (schemaType instanceof GenericType) { // model
|
||||
try {
|
||||
Object deserializedObject = deserialize(response, schemaType);
|
||||
if (deserializedObject != null) {
|
||||
result = deserializedObject;
|
||||
matchCounter++;
|
||||
|
||||
if ("anyOf".equals(schema.getSchemaType())) {
|
||||
break;
|
||||
} else if ("oneOf".equals(schema.getSchemaType())) {
|
||||
matchSchemas.add(schemaName);
|
||||
} else {
|
||||
throw new ApiException("Unknowe type found while expecting anyOf/oneOf:" + schema.getSchemaType());
|
||||
}
|
||||
} else {
|
||||
// failed to deserialize the response in the schema provided, proceed to the next one if any
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// failed to deserialize, do nothing and try next one (schema)
|
||||
// Logging the error may be useful to troubleshoot why a payload fails to match
|
||||
// the schema.
|
||||
log.log(Level.FINE, "Input data does not match schema '" + schemaName + "'", ex);
|
||||
}
|
||||
} else {// unknown type
|
||||
throw new ApiException(schemaType.getClass() + " is not a GenericType and cannot be handled properly in deserialization.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (matchCounter > 1 && "oneOf".equals(schema.getSchemaType())) {// more than 1 match for oneOf
|
||||
throw new ApiException("Response body is invalid as it matches more than one schema (" + StringUtil.join(matchSchemas, ", ") + ") defined in the oneOf model: " + schema.getClass().getName());
|
||||
} else if (matchCounter == 0) { // fail to match any in oneOf/anyOf schemas
|
||||
throw new ApiException("Response body is invalid as it does not match any schemas (" + StringUtil.join(schema.getSchemas().keySet(), ", ") + ") defined in the oneOf/anyOf model: " + schema.getClass().getName());
|
||||
} else { // only one matched
|
||||
schema.setActualInstance(result);
|
||||
return schema;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Deserialize response body to Java object according to the Content-Type.
|
||||
* @param <T> Type
|
||||
@@ -1052,7 +990,6 @@ public class ApiClient {
|
||||
* @param contentType The request's Content-Type header
|
||||
* @param authNames The authentications to apply
|
||||
* @param returnType The return type into which to deserialize the response
|
||||
* @param schema An instance of the response that uses oneOf/anyOf
|
||||
* @return The response body in type of string
|
||||
* @throws ApiException API exception
|
||||
*/
|
||||
@@ -1068,8 +1005,7 @@ public class ApiClient {
|
||||
String accept,
|
||||
String contentType,
|
||||
String[] authNames,
|
||||
GenericType<T> returnType,
|
||||
AbstractOpenApiSchema schema)
|
||||
GenericType<T> returnType)
|
||||
throws ApiException {
|
||||
|
||||
// Not using `.target(targetURL).path(path)` below,
|
||||
@@ -1166,12 +1102,10 @@ public class ApiClient {
|
||||
if (response.getStatusInfo() == Status.NO_CONTENT) {
|
||||
return new ApiResponse<T>(statusCode, responseHeaders);
|
||||
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
|
||||
if (returnType == null) return new ApiResponse<T>(statusCode, responseHeaders);
|
||||
else if (schema == null) {
|
||||
if (returnType == null) {
|
||||
return new ApiResponse<T>(statusCode, responseHeaders);
|
||||
} else {
|
||||
return new ApiResponse<T>(statusCode, responseHeaders, deserialize(response, returnType));
|
||||
} else { // oneOf/anyOf
|
||||
return new ApiResponse<T>(
|
||||
statusCode, responseHeaders, (T) deserializeSchemas(response, schema));
|
||||
}
|
||||
} else {
|
||||
String message = "error";
|
||||
@@ -1217,8 +1151,8 @@ public class ApiClient {
|
||||
* @deprecated Add qualified name of the operation as a first parameter.
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType, AbstractOpenApiSchema schema) throws ApiException {
|
||||
return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType, schema);
|
||||
public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
|
||||
return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,9 +4,14 @@ import com.fasterxml.jackson.annotation.*;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.openapitools.client.model.*;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.ext.ContextResolver;
|
||||
|
||||
|
||||
@@ -46,4 +51,197 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
* @return object mapper
|
||||
*/
|
||||
public ObjectMapper getMapper() { return mapper; }
|
||||
|
||||
/**
|
||||
* Returns the target model class that should be used to deserialize the input data.
|
||||
* The discriminator mappings are used to determine the target model class.
|
||||
*
|
||||
* @param node The input data.
|
||||
* @param modelClass The class that contains the discriminator mappings.
|
||||
*/
|
||||
public static Class getClassForElement(JsonNode node, Class modelClass) {
|
||||
ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass);
|
||||
if (cdm != null) {
|
||||
return cdm.getClassForElement(node, new HashSet<Class>());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to register the discriminator mappings.
|
||||
*/
|
||||
private static class ClassDiscriminatorMapping {
|
||||
// The model class name.
|
||||
Class modelClass;
|
||||
// The name of the discriminator property.
|
||||
String discriminatorName;
|
||||
// The discriminator mappings for a model class.
|
||||
Map<String, Class> discriminatorMappings;
|
||||
|
||||
// Constructs a new class discriminator.
|
||||
ClassDiscriminatorMapping(Class cls, String propertyName, Map<String, Class> mappings) {
|
||||
modelClass = cls;
|
||||
discriminatorName = propertyName;
|
||||
discriminatorMappings = new HashMap<String, Class>();
|
||||
if (mappings != null) {
|
||||
discriminatorMappings.putAll(mappings);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the name of the discriminator property for this model class.
|
||||
String getDiscriminatorPropertyName() {
|
||||
return discriminatorName;
|
||||
}
|
||||
|
||||
// Return the discriminator value or null if the discriminator is not
|
||||
// present in the payload.
|
||||
String getDiscriminatorValue(JsonNode node) {
|
||||
// Determine the value of the discriminator property in the input data.
|
||||
if (discriminatorName != null) {
|
||||
// Get the value of the discriminator property, if present in the input payload.
|
||||
node = node.get(discriminatorName);
|
||||
if (node != null && node.isValueNode()) {
|
||||
String discrValue = node.asText();
|
||||
if (discrValue != null) {
|
||||
return discrValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target model class that should be used to deserialize the input data.
|
||||
* This function can be invoked for anyOf/oneOf composed models with discriminator mappings.
|
||||
* The discriminator mappings are used to determine the target model class.
|
||||
*
|
||||
* @param node The input data.
|
||||
* @param visitedClasses The set of classes that have already been visited.
|
||||
*/
|
||||
Class getClassForElement(JsonNode node, Set<Class> visitedClasses) {
|
||||
if (visitedClasses.contains(modelClass)) {
|
||||
// Class has already been visited.
|
||||
return null;
|
||||
}
|
||||
// Determine the value of the discriminator property in the input data.
|
||||
String discrValue = getDiscriminatorValue(node);
|
||||
if (discrValue == null) {
|
||||
return null;
|
||||
}
|
||||
Class cls = discriminatorMappings.get(discrValue);
|
||||
// It may not be sufficient to return this cls directly because that target class
|
||||
// may itself be a composed schema, possibly with its own discriminator.
|
||||
visitedClasses.add(modelClass);
|
||||
for (Class childClass : discriminatorMappings.values()) {
|
||||
ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass);
|
||||
if (childCdm == null) {
|
||||
continue;
|
||||
}
|
||||
if (!discriminatorName.equals(childCdm.discriminatorName)) {
|
||||
discrValue = getDiscriminatorValue(node);
|
||||
if (discrValue == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (childCdm != null) {
|
||||
// Recursively traverse the discriminator mappings.
|
||||
Class childDiscr = childCdm.getClassForElement(node, visitedClasses);
|
||||
if (childDiscr != null) {
|
||||
return childDiscr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cls;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy.
|
||||
*
|
||||
* The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy,
|
||||
* so it's not possible to use the instanceof keyword.
|
||||
*
|
||||
* @param modelClass A OpenAPI model class.
|
||||
* @param inst The instance object.
|
||||
*/
|
||||
public static boolean isInstanceOf(Class modelClass, Object inst, Set<Class> visitedClasses) {
|
||||
if (modelClass.isInstance(inst)) {
|
||||
// This handles the 'allOf' use case with single parent inheritance.
|
||||
return true;
|
||||
}
|
||||
if (visitedClasses.contains(modelClass)) {
|
||||
// This is to prevent infinite recursion when the composed schemas have
|
||||
// a circular dependency.
|
||||
return false;
|
||||
}
|
||||
visitedClasses.add(modelClass);
|
||||
|
||||
// Traverse the oneOf/anyOf composed schemas.
|
||||
Map<String, GenericType> descendants = modelDescendants.get(modelClass);
|
||||
if (descendants != null) {
|
||||
for (GenericType childType : descendants.values()) {
|
||||
if (isInstanceOf(childType.getRawType(), inst, visitedClasses)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of discriminators for all model classes.
|
||||
*/
|
||||
private static Map<Class, ClassDiscriminatorMapping> modelDiscriminators = new HashMap<Class, ClassDiscriminatorMapping>();
|
||||
|
||||
/**
|
||||
* A map of oneOf/anyOf descendants for each model class.
|
||||
*/
|
||||
private static Map<Class, Map<String, GenericType>> modelDescendants = new HashMap<Class, Map<String, GenericType>>();
|
||||
|
||||
/**
|
||||
* Register a model class discriminator.
|
||||
*
|
||||
* @param modelClass the model class
|
||||
* @param discriminatorPropertyName the name of the discriminator property
|
||||
* @param mappings a map with the discriminator mappings.
|
||||
*/
|
||||
public static void registerDiscriminator(Class modelClass, String discriminatorPropertyName, Map<String, Class> mappings) {
|
||||
ClassDiscriminatorMapping m = new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings);
|
||||
modelDiscriminators.put(modelClass, m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the oneOf/anyOf descendants of the modelClass.
|
||||
*
|
||||
* @param modelClass the model class
|
||||
* @param descendants a map of oneOf/anyOf descendants.
|
||||
*/
|
||||
public static void registerDescendants(Class modelClass, Map<String, GenericType> descendants) {
|
||||
modelDescendants.put(modelClass, descendants);
|
||||
}
|
||||
|
||||
private static JSON json;
|
||||
|
||||
static
|
||||
{
|
||||
json = new JSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default JSON instance.
|
||||
*
|
||||
* @return the default JSON instance
|
||||
*/
|
||||
public static JSON getDefault() {
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default JSON instance.
|
||||
*
|
||||
* @param json JSON instance to be used
|
||||
*/
|
||||
public static void setDefault(JSON json) {
|
||||
JSON.json = json;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,6 @@ public class AnotherFakeApi {
|
||||
|
||||
return apiClient.invokeAPI("AnotherFakeApi.call123testSpecialTags", localVarPath, "PATCH", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,6 @@ public class DefaultApi {
|
||||
|
||||
return apiClient.invokeAPI("DefaultApi.fooGet", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.fakeHealthGet", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -174,7 +174,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.fakeOuterBooleanSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -236,7 +236,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.fakeOuterCompositeSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -298,7 +298,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.fakeOuterNumberSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -360,7 +360,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.fakeOuterStringSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Array of Enums
|
||||
@@ -420,7 +420,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.getArrayOfEnums", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -484,7 +484,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testBodyWithFileSchema", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -556,7 +556,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testBodyWithQueryParams", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* To test \"client\" model
|
||||
@@ -623,7 +623,7 @@ public class FakeApi {
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testClientModel", localVarPath, "PATCH", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@@ -758,7 +758,7 @@ if (paramCallback != null)
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testEndpointParameters", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* To test enum parameters
|
||||
@@ -845,7 +845,7 @@ if (enumFormString != null)
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testEnumParameters", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
|
||||
private ApiResponse<Void> testGroupParametersWithHttpInfo(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws ApiException {
|
||||
@@ -901,7 +901,7 @@ if (booleanGroup != null)
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testGroupParameters", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
|
||||
public class APItestGroupParametersRequest {
|
||||
@@ -1080,7 +1080,7 @@ if (booleanGroup != null)
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testInlineAdditionalProperties", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* test json serialization of form data
|
||||
@@ -1155,7 +1155,7 @@ if (param2 != null)
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testJsonFormData", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -1252,6 +1252,6 @@ if (param2 != null)
|
||||
|
||||
return apiClient.invokeAPI("FakeApi.testQueryParameterCollectionFormat", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,6 @@ public class FakeClassnameTags123Api {
|
||||
|
||||
return apiClient.invokeAPI("FakeClassnameTags123Api.testClassname", localVarPath, "PATCH", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public class PetApi {
|
||||
|
||||
return apiClient.invokeAPI("PetApi.addPet", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Deletes a pet
|
||||
@@ -178,7 +178,7 @@ public class PetApi {
|
||||
|
||||
return apiClient.invokeAPI("PetApi.deletePet", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Finds Pets by status
|
||||
@@ -248,7 +248,7 @@ public class PetApi {
|
||||
|
||||
return apiClient.invokeAPI("PetApi.findPetsByStatus", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
@@ -322,7 +322,7 @@ public class PetApi {
|
||||
|
||||
return apiClient.invokeAPI("PetApi.findPetsByTags", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Find pet by ID
|
||||
@@ -394,7 +394,7 @@ public class PetApi {
|
||||
|
||||
return apiClient.invokeAPI("PetApi.getPetById", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Update an existing pet
|
||||
@@ -462,7 +462,7 @@ public class PetApi {
|
||||
|
||||
return apiClient.invokeAPI("PetApi.updatePet", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
@@ -535,7 +535,7 @@ if (status != null)
|
||||
|
||||
return apiClient.invokeAPI("PetApi.updatePetWithForm", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* uploads an image
|
||||
@@ -611,7 +611,7 @@ if (file != null)
|
||||
|
||||
return apiClient.invokeAPI("PetApi.uploadFile", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* uploads an image (required)
|
||||
@@ -692,6 +692,6 @@ if (requiredFile != null)
|
||||
|
||||
return apiClient.invokeAPI("PetApi.uploadFileWithRequiredFile", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class StoreApi {
|
||||
|
||||
return apiClient.invokeAPI("StoreApi.deleteOrder", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
@@ -170,7 +170,7 @@ public class StoreApi {
|
||||
|
||||
return apiClient.invokeAPI("StoreApi.getInventory", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
@@ -242,7 +242,7 @@ public class StoreApi {
|
||||
|
||||
return apiClient.invokeAPI("StoreApi.getOrderById", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Place an order for a pet
|
||||
@@ -311,6 +311,6 @@ public class StoreApi {
|
||||
|
||||
return apiClient.invokeAPI("StoreApi.placeOrder", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.createUser", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
@@ -171,7 +171,7 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.createUsersWithArrayInput", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
@@ -235,7 +235,7 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.createUsersWithListInput", localVarPath, "POST", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Delete user
|
||||
@@ -302,7 +302,7 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.deleteUser", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Get user by user name
|
||||
@@ -374,7 +374,7 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.getUserByName", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Logs user into the system
|
||||
@@ -452,7 +452,7 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.loginUser", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, localVarReturnType, null);
|
||||
localVarAuthNames, localVarReturnType);
|
||||
}
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
@@ -509,7 +509,7 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.logoutUser", localVarPath, "GET", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
/**
|
||||
* Updated user
|
||||
@@ -583,6 +583,6 @@ public class UserApi {
|
||||
|
||||
return apiClient.invokeAPI("UserApi.updateUser", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
|
||||
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
|
||||
localVarAuthNames, null, null);
|
||||
localVarAuthNames, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ public abstract class AbstractOpenApiSchema {
|
||||
this.isNullable = isNullable;
|
||||
}
|
||||
|
||||
/***
|
||||
* Get the list of schemas allowed to be stored in this object
|
||||
/**
|
||||
* Get the list of oneOf/anyOf composed schemas allowed to be stored in this object
|
||||
*
|
||||
* @return an instance of the actual schema/object
|
||||
*/
|
||||
public abstract Map<String, GenericType> getSchemas();
|
||||
|
||||
/***
|
||||
/**
|
||||
* Get the actual instance
|
||||
*
|
||||
* @return an instance of the actual schema/object
|
||||
@@ -56,14 +56,14 @@ public abstract class AbstractOpenApiSchema {
|
||||
@JsonValue
|
||||
public Object getActualInstance() {return instance;}
|
||||
|
||||
/***
|
||||
/**
|
||||
* Set the actual instance
|
||||
*
|
||||
* @param instance the actual instance of the schema/object
|
||||
*/
|
||||
public void setActualInstance(Object instance) {this.instance = instance;}
|
||||
|
||||
/***
|
||||
/**
|
||||
* Get the schema type (e.g. anyOf, oneOf)
|
||||
*
|
||||
* @return the schema type
|
||||
@@ -112,7 +112,7 @@ public abstract class AbstractOpenApiSchema {
|
||||
return Objects.hash(instance, isNullable, schemaType);
|
||||
}
|
||||
|
||||
/***
|
||||
/**
|
||||
* Is nullalble
|
||||
*
|
||||
* @return true if it's nullable
|
||||
@@ -124,4 +124,7 @@ public abstract class AbstractOpenApiSchema {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -28,6 +30,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesClass
|
||||
@@ -70,7 +74,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
|
||||
public AdditionalPropertiesClass mapProperty(Map<String, String> mapProperty) {
|
||||
|
||||
this.mapProperty = mapProperty;
|
||||
return this;
|
||||
}
|
||||
@@ -103,7 +106,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
|
||||
public AdditionalPropertiesClass mapOfMapProperty(Map<String, Map<String, String>> mapOfMapProperty) {
|
||||
|
||||
this.mapOfMapProperty = mapOfMapProperty;
|
||||
return this;
|
||||
}
|
||||
@@ -137,7 +139,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
public AdditionalPropertiesClass anytype1(Object anytype1) {
|
||||
this.anytype1 = JsonNullable.<Object>of(anytype1);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -171,7 +172,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
|
||||
public AdditionalPropertiesClass mapWithUndeclaredPropertiesAnytype1(Object mapWithUndeclaredPropertiesAnytype1) {
|
||||
|
||||
this.mapWithUndeclaredPropertiesAnytype1 = mapWithUndeclaredPropertiesAnytype1;
|
||||
return this;
|
||||
}
|
||||
@@ -196,7 +196,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
|
||||
public AdditionalPropertiesClass mapWithUndeclaredPropertiesAnytype2(Object mapWithUndeclaredPropertiesAnytype2) {
|
||||
|
||||
this.mapWithUndeclaredPropertiesAnytype2 = mapWithUndeclaredPropertiesAnytype2;
|
||||
return this;
|
||||
}
|
||||
@@ -221,7 +220,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
|
||||
public AdditionalPropertiesClass mapWithUndeclaredPropertiesAnytype3(Map<String, Object> mapWithUndeclaredPropertiesAnytype3) {
|
||||
|
||||
this.mapWithUndeclaredPropertiesAnytype3 = mapWithUndeclaredPropertiesAnytype3;
|
||||
return this;
|
||||
}
|
||||
@@ -254,7 +252,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
|
||||
public AdditionalPropertiesClass emptyMap(Object emptyMap) {
|
||||
|
||||
this.emptyMap = emptyMap;
|
||||
return this;
|
||||
}
|
||||
@@ -279,7 +276,6 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
|
||||
public AdditionalPropertiesClass mapWithUndeclaredPropertiesString(Map<String, String> mapWithUndeclaredPropertiesString) {
|
||||
|
||||
this.mapWithUndeclaredPropertiesString = mapWithUndeclaredPropertiesString;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.Cat;
|
||||
import org.openapitools.client.model.Dog;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Animal
|
||||
@@ -50,7 +54,6 @@ public class Animal {
|
||||
|
||||
|
||||
public Animal className(String className) {
|
||||
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
@@ -74,7 +77,6 @@ public class Animal {
|
||||
|
||||
|
||||
public Animal color(String color) {
|
||||
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
@@ -138,5 +140,13 @@ public class Animal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("Cat", Cat.class);
|
||||
mappings.put("Dog", Dog.class);
|
||||
mappings.put("Animal", Animal.class);
|
||||
JSON.registerDiscriminator(Animal.class, "className", mappings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Apple
|
||||
@@ -40,7 +44,6 @@ public class Apple {
|
||||
|
||||
|
||||
public Apple cultivar(String cultivar) {
|
||||
|
||||
this.cultivar = cultivar;
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +68,6 @@ public class Apple {
|
||||
|
||||
|
||||
public Apple origin(String origin) {
|
||||
|
||||
this.origin = origin;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* AppleReq
|
||||
@@ -40,7 +44,6 @@ public class AppleReq {
|
||||
|
||||
|
||||
public AppleReq cultivar(String cultivar) {
|
||||
|
||||
this.cultivar = cultivar;
|
||||
return this;
|
||||
}
|
||||
@@ -64,7 +67,6 @@ public class AppleReq {
|
||||
|
||||
|
||||
public AppleReq mealy(Boolean mealy) {
|
||||
|
||||
this.mealy = mealy;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,8 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly
|
||||
@@ -39,7 +43,6 @@ public class ArrayOfArrayOfNumberOnly {
|
||||
|
||||
|
||||
public ArrayOfArrayOfNumberOnly arrayArrayNumber(List<List<BigDecimal>> arrayArrayNumber) {
|
||||
|
||||
this.arrayArrayNumber = arrayArrayNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,8 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ArrayOfNumberOnly
|
||||
@@ -39,7 +43,6 @@ public class ArrayOfNumberOnly {
|
||||
|
||||
|
||||
public ArrayOfNumberOnly arrayNumber(List<BigDecimal> arrayNumber) {
|
||||
|
||||
this.arrayNumber = arrayNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.ReadOnlyFirst;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ArrayTest
|
||||
@@ -47,7 +51,6 @@ public class ArrayTest {
|
||||
|
||||
|
||||
public ArrayTest arrayOfString(List<String> arrayOfString) {
|
||||
|
||||
this.arrayOfString = arrayOfString;
|
||||
return this;
|
||||
}
|
||||
@@ -80,7 +83,6 @@ public class ArrayTest {
|
||||
|
||||
|
||||
public ArrayTest arrayArrayOfInteger(List<List<Long>> arrayArrayOfInteger) {
|
||||
|
||||
this.arrayArrayOfInteger = arrayArrayOfInteger;
|
||||
return this;
|
||||
}
|
||||
@@ -113,7 +115,6 @@ public class ArrayTest {
|
||||
|
||||
|
||||
public ArrayTest arrayArrayOfModel(List<List<ReadOnlyFirst>> arrayArrayOfModel) {
|
||||
|
||||
this.arrayArrayOfModel = arrayArrayOfModel;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Banana
|
||||
@@ -37,7 +41,6 @@ public class Banana {
|
||||
|
||||
|
||||
public Banana lengthCm(BigDecimal lengthCm) {
|
||||
|
||||
this.lengthCm = lengthCm;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* BananaReq
|
||||
@@ -41,7 +45,6 @@ public class BananaReq {
|
||||
|
||||
|
||||
public BananaReq lengthCm(BigDecimal lengthCm) {
|
||||
|
||||
this.lengthCm = lengthCm;
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +68,6 @@ public class BananaReq {
|
||||
|
||||
|
||||
public BananaReq sweet(Boolean sweet) {
|
||||
|
||||
this.sweet = sweet;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* BasquePig
|
||||
@@ -36,7 +40,6 @@ public class BasquePig {
|
||||
|
||||
|
||||
public BasquePig className(String className) {
|
||||
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Capitalization
|
||||
@@ -56,7 +60,6 @@ public class Capitalization {
|
||||
|
||||
|
||||
public Capitalization smallCamel(String smallCamel) {
|
||||
|
||||
this.smallCamel = smallCamel;
|
||||
return this;
|
||||
}
|
||||
@@ -81,7 +84,6 @@ public class Capitalization {
|
||||
|
||||
|
||||
public Capitalization capitalCamel(String capitalCamel) {
|
||||
|
||||
this.capitalCamel = capitalCamel;
|
||||
return this;
|
||||
}
|
||||
@@ -106,7 +108,6 @@ public class Capitalization {
|
||||
|
||||
|
||||
public Capitalization smallSnake(String smallSnake) {
|
||||
|
||||
this.smallSnake = smallSnake;
|
||||
return this;
|
||||
}
|
||||
@@ -131,7 +132,6 @@ public class Capitalization {
|
||||
|
||||
|
||||
public Capitalization capitalSnake(String capitalSnake) {
|
||||
|
||||
this.capitalSnake = capitalSnake;
|
||||
return this;
|
||||
}
|
||||
@@ -156,7 +156,6 @@ public class Capitalization {
|
||||
|
||||
|
||||
public Capitalization scAETHFlowPoints(String scAETHFlowPoints) {
|
||||
|
||||
this.scAETHFlowPoints = scAETHFlowPoints;
|
||||
return this;
|
||||
}
|
||||
@@ -181,7 +180,6 @@ public class Capitalization {
|
||||
|
||||
|
||||
public Capitalization ATT_NAME(String ATT_NAME) {
|
||||
|
||||
this.ATT_NAME = ATT_NAME;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import org.openapitools.client.model.CatAllOf;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Cat
|
||||
@@ -44,7 +48,6 @@ public class Cat extends Animal {
|
||||
|
||||
|
||||
public Cat declawed(Boolean declawed) {
|
||||
|
||||
this.declawed = declawed;
|
||||
return this;
|
||||
}
|
||||
@@ -108,5 +111,11 @@ public class Cat extends Animal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("Cat", Cat.class);
|
||||
JSON.registerDiscriminator(Cat.class, "className", mappings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* CatAllOf
|
||||
@@ -36,7 +40,6 @@ public class CatAllOf {
|
||||
|
||||
|
||||
public CatAllOf declawed(Boolean declawed) {
|
||||
|
||||
this.declawed = declawed;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Category
|
||||
@@ -40,7 +44,6 @@ public class Category {
|
||||
|
||||
|
||||
public Category id(Long id) {
|
||||
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +68,6 @@ public class Category {
|
||||
|
||||
|
||||
public Category name(String name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.ChildCatAllOf;
|
||||
import org.openapitools.client.model.ParentPet;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ChildCat
|
||||
@@ -44,7 +48,6 @@ public class ChildCat extends ParentPet {
|
||||
|
||||
|
||||
public ChildCat name(String name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -108,5 +111,11 @@ public class ChildCat extends ParentPet {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("ChildCat", ChildCat.class);
|
||||
JSON.registerDiscriminator(ChildCat.class, "pet_type", mappings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ChildCatAllOf
|
||||
@@ -36,7 +40,6 @@ public class ChildCatAllOf {
|
||||
|
||||
|
||||
public ChildCatAllOf name(String name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing model with \"_class\" property
|
||||
@@ -37,7 +41,6 @@ public class ClassModel {
|
||||
|
||||
|
||||
public ClassModel propertyClass(String propertyClass) {
|
||||
|
||||
this.propertyClass = propertyClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Client
|
||||
@@ -36,7 +40,6 @@ public class Client {
|
||||
|
||||
|
||||
public Client client(String client) {
|
||||
|
||||
this.client = client;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.QuadrilateralInterface;
|
||||
import org.openapitools.client.model.ShapeInterface;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ComplexQuadrilateral
|
||||
@@ -42,7 +46,6 @@ public class ComplexQuadrilateral {
|
||||
|
||||
|
||||
public ComplexQuadrilateral shapeType(String shapeType) {
|
||||
|
||||
this.shapeType = shapeType;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class ComplexQuadrilateral {
|
||||
|
||||
|
||||
public ComplexQuadrilateral quadrilateralType(String quadrilateralType) {
|
||||
|
||||
this.quadrilateralType = quadrilateralType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* DanishPig
|
||||
@@ -36,7 +40,6 @@ public class DanishPig {
|
||||
|
||||
|
||||
public DanishPig className(String className) {
|
||||
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import org.openapitools.client.model.DogAllOf;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Dog
|
||||
@@ -44,7 +48,6 @@ public class Dog extends Animal {
|
||||
|
||||
|
||||
public Dog breed(String breed) {
|
||||
|
||||
this.breed = breed;
|
||||
return this;
|
||||
}
|
||||
@@ -108,5 +111,11 @@ public class Dog extends Animal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("Dog", Dog.class);
|
||||
JSON.registerDiscriminator(Dog.class, "className", mappings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* DogAllOf
|
||||
@@ -36,7 +40,6 @@ public class DogAllOf {
|
||||
|
||||
|
||||
public DogAllOf breed(String breed) {
|
||||
|
||||
this.breed = breed;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,14 @@
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,9 +28,7 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.openapitools.client.model.Fruit;
|
||||
import org.openapitools.client.model.NullableShape;
|
||||
import org.openapitools.client.model.Shape;
|
||||
@@ -33,6 +37,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Drawing
|
||||
@@ -44,7 +50,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
Drawing.JSON_PROPERTY_SHAPES
|
||||
})
|
||||
|
||||
public class Drawing extends HashMap<String, Fruit> {
|
||||
public class Drawing {
|
||||
public static final String JSON_PROPERTY_MAIN_SHAPE = "mainShape";
|
||||
private Shape mainShape = null;
|
||||
|
||||
@@ -59,7 +65,6 @@ public class Drawing extends HashMap<String, Fruit> {
|
||||
|
||||
|
||||
public Drawing mainShape(Shape mainShape) {
|
||||
|
||||
this.mainShape = mainShape;
|
||||
return this;
|
||||
}
|
||||
@@ -84,7 +89,6 @@ public class Drawing extends HashMap<String, Fruit> {
|
||||
|
||||
|
||||
public Drawing shapeOrNull(ShapeOrNull shapeOrNull) {
|
||||
|
||||
this.shapeOrNull = shapeOrNull;
|
||||
return this;
|
||||
}
|
||||
@@ -110,7 +114,6 @@ public class Drawing extends HashMap<String, Fruit> {
|
||||
|
||||
public Drawing nullableShape(NullableShape nullableShape) {
|
||||
this.nullableShape = JsonNullable.<NullableShape>of(nullableShape);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -144,7 +147,6 @@ public class Drawing extends HashMap<String, Fruit> {
|
||||
|
||||
|
||||
public Drawing shapes(List<Shape> shapes) {
|
||||
|
||||
this.shapes = shapes;
|
||||
return this;
|
||||
}
|
||||
@@ -175,6 +177,43 @@ public class Drawing extends HashMap<String, Fruit> {
|
||||
this.shapes = shapes;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Fruit> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public Drawing putAdditionalProperty(String key, Fruit value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Fruit>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*/
|
||||
@JsonAnyGetter
|
||||
public Map<String, Fruit> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*/
|
||||
public Fruit getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
@@ -188,13 +227,13 @@ public class Drawing extends HashMap<String, Fruit> {
|
||||
return Objects.equals(this.mainShape, drawing.mainShape) &&
|
||||
Objects.equals(this.shapeOrNull, drawing.shapeOrNull) &&
|
||||
Objects.equals(this.nullableShape, drawing.nullableShape) &&
|
||||
Objects.equals(this.shapes, drawing.shapes) &&
|
||||
super.equals(o);
|
||||
Objects.equals(this.shapes, drawing.shapes)&&
|
||||
Objects.equals(this.additionalProperties, drawing.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mainShape, shapeOrNull, nullableShape, shapes, super.hashCode());
|
||||
return Objects.hash(mainShape, shapeOrNull, nullableShape, shapes, additionalProperties);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,11 +241,11 @@ public class Drawing extends HashMap<String, Fruit> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Drawing {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" mainShape: ").append(toIndentedString(mainShape)).append("\n");
|
||||
sb.append(" shapeOrNull: ").append(toIndentedString(shapeOrNull)).append("\n");
|
||||
sb.append(" nullableShape: ").append(toIndentedString(nullableShape)).append("\n");
|
||||
sb.append(" shapes: ").append(toIndentedString(shapes)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* EnumArrays
|
||||
@@ -112,7 +116,6 @@ public class EnumArrays {
|
||||
|
||||
|
||||
public EnumArrays justSymbol(JustSymbolEnum justSymbol) {
|
||||
|
||||
this.justSymbol = justSymbol;
|
||||
return this;
|
||||
}
|
||||
@@ -137,7 +140,6 @@ public class EnumArrays {
|
||||
|
||||
|
||||
public EnumArrays arrayEnum(List<ArrayEnumEnum> arrayEnum) {
|
||||
|
||||
this.arrayEnum = arrayEnum;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,11 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -29,6 +31,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* EnumTest
|
||||
@@ -215,7 +219,6 @@ public class EnumTest {
|
||||
|
||||
|
||||
public EnumTest enumString(EnumStringEnum enumString) {
|
||||
|
||||
this.enumString = enumString;
|
||||
return this;
|
||||
}
|
||||
@@ -240,7 +243,6 @@ public class EnumTest {
|
||||
|
||||
|
||||
public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) {
|
||||
|
||||
this.enumStringRequired = enumStringRequired;
|
||||
return this;
|
||||
}
|
||||
@@ -264,7 +266,6 @@ public class EnumTest {
|
||||
|
||||
|
||||
public EnumTest enumInteger(EnumIntegerEnum enumInteger) {
|
||||
|
||||
this.enumInteger = enumInteger;
|
||||
return this;
|
||||
}
|
||||
@@ -289,7 +290,6 @@ public class EnumTest {
|
||||
|
||||
|
||||
public EnumTest enumNumber(EnumNumberEnum enumNumber) {
|
||||
|
||||
this.enumNumber = enumNumber;
|
||||
return this;
|
||||
}
|
||||
@@ -315,7 +315,6 @@ public class EnumTest {
|
||||
|
||||
public EnumTest outerEnum(OuterEnum outerEnum) {
|
||||
this.outerEnum = JsonNullable.<OuterEnum>of(outerEnum);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -349,7 +348,6 @@ public class EnumTest {
|
||||
|
||||
|
||||
public EnumTest outerEnumInteger(OuterEnumInteger outerEnumInteger) {
|
||||
|
||||
this.outerEnumInteger = outerEnumInteger;
|
||||
return this;
|
||||
}
|
||||
@@ -374,7 +372,6 @@ public class EnumTest {
|
||||
|
||||
|
||||
public EnumTest outerEnumDefaultValue(OuterEnumDefaultValue outerEnumDefaultValue) {
|
||||
|
||||
this.outerEnumDefaultValue = outerEnumDefaultValue;
|
||||
return this;
|
||||
}
|
||||
@@ -399,7 +396,6 @@ public class EnumTest {
|
||||
|
||||
|
||||
public EnumTest outerEnumIntegerDefaultValue(OuterEnumIntegerDefaultValue outerEnumIntegerDefaultValue) {
|
||||
|
||||
this.outerEnumIntegerDefaultValue = outerEnumIntegerDefaultValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.ShapeInterface;
|
||||
import org.openapitools.client.model.TriangleInterface;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* EquilateralTriangle
|
||||
@@ -42,7 +46,6 @@ public class EquilateralTriangle {
|
||||
|
||||
|
||||
public EquilateralTriangle shapeType(String shapeType) {
|
||||
|
||||
this.shapeType = shapeType;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class EquilateralTriangle {
|
||||
|
||||
|
||||
public EquilateralTriangle triangleType(String triangleType) {
|
||||
|
||||
this.triangleType = triangleType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* FileSchemaTestClass
|
||||
@@ -42,7 +46,6 @@ public class FileSchemaTestClass {
|
||||
|
||||
|
||||
public FileSchemaTestClass file(java.io.File file) {
|
||||
|
||||
this.file = file;
|
||||
return this;
|
||||
}
|
||||
@@ -67,7 +70,6 @@ public class FileSchemaTestClass {
|
||||
|
||||
|
||||
public FileSchemaTestClass files(List<java.io.File> files) {
|
||||
|
||||
this.files = files;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Foo
|
||||
@@ -36,7 +40,6 @@ public class Foo {
|
||||
|
||||
|
||||
public Foo bar(String bar) {
|
||||
|
||||
this.bar = bar;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -27,6 +29,8 @@ import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.UUID;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* FormatTest
|
||||
@@ -97,7 +101,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest integer(Integer integer) {
|
||||
|
||||
this.integer = integer;
|
||||
return this;
|
||||
}
|
||||
@@ -124,7 +127,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest int32(Integer int32) {
|
||||
|
||||
this.int32 = int32;
|
||||
return this;
|
||||
}
|
||||
@@ -151,7 +153,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest int64(Long int64) {
|
||||
|
||||
this.int64 = int64;
|
||||
return this;
|
||||
}
|
||||
@@ -176,7 +177,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest number(BigDecimal number) {
|
||||
|
||||
this.number = number;
|
||||
return this;
|
||||
}
|
||||
@@ -202,7 +202,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest _float(Float _float) {
|
||||
|
||||
this._float = _float;
|
||||
return this;
|
||||
}
|
||||
@@ -229,7 +228,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest _double(Double _double) {
|
||||
|
||||
this._double = _double;
|
||||
return this;
|
||||
}
|
||||
@@ -256,7 +254,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest string(String string) {
|
||||
|
||||
this.string = string;
|
||||
return this;
|
||||
}
|
||||
@@ -281,7 +278,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest _byte(byte[] _byte) {
|
||||
|
||||
this._byte = _byte;
|
||||
return this;
|
||||
}
|
||||
@@ -305,7 +301,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest binary(File binary) {
|
||||
|
||||
this.binary = binary;
|
||||
return this;
|
||||
}
|
||||
@@ -330,7 +325,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest date(LocalDate date) {
|
||||
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
@@ -354,7 +348,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest dateTime(OffsetDateTime dateTime) {
|
||||
|
||||
this.dateTime = dateTime;
|
||||
return this;
|
||||
}
|
||||
@@ -379,7 +372,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest uuid(UUID uuid) {
|
||||
|
||||
this.uuid = uuid;
|
||||
return this;
|
||||
}
|
||||
@@ -404,7 +396,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest password(String password) {
|
||||
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
@@ -428,7 +419,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest patternWithDigits(String patternWithDigits) {
|
||||
|
||||
this.patternWithDigits = patternWithDigits;
|
||||
return this;
|
||||
}
|
||||
@@ -453,7 +443,6 @@ public class FormatTest {
|
||||
|
||||
|
||||
public FormatTest patternWithDigitsAndDelimiter(String patternWithDigitsAndDelimiter) {
|
||||
|
||||
this.patternWithDigitsAndDelimiter = patternWithDigitsAndDelimiter;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,9 @@ import java.math.BigDecimal;
|
||||
import org.openapitools.client.model.Apple;
|
||||
import org.openapitools.client.model.Banana;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -32,21 +37,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=Fruit.FruitDeserializer.class)
|
||||
@JsonDeserialize(using = Fruit.FruitDeserializer.class)
|
||||
@JsonSerialize(using = Fruit.FruitSerializer.class)
|
||||
public class Fruit extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(Fruit.class.getName());
|
||||
|
||||
public static class FruitSerializer extends StdSerializer<Fruit> {
|
||||
public FruitSerializer(Class<Fruit> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public FruitSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Fruit value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class FruitDeserializer extends StdDeserializer<Fruit> {
|
||||
public FruitDeserializer() {
|
||||
this(Fruit.class);
|
||||
@@ -59,12 +87,14 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public Fruit deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
int match = 0;
|
||||
// deserialize Apple
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Apple.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Apple'");
|
||||
} catch (Exception e) {
|
||||
@@ -75,6 +105,9 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
// deserialize Banana
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Banana.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Banana'");
|
||||
} catch (Exception e) {
|
||||
@@ -89,6 +122,15 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for Fruit: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public Fruit getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
throw new JsonMappingException("Fruit cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -113,6 +155,7 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("Banana", new GenericType<Banana>() {
|
||||
});
|
||||
JSON.registerDescendants(Fruit.class, Collections.unmodifiableMap(schemas));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,14 +163,21 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
return Fruit.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof Apple) {
|
||||
if (JSON.isInstanceOf(Apple.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Banana) {
|
||||
if (JSON.isInstanceOf(Banana.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,9 @@ import java.math.BigDecimal;
|
||||
import org.openapitools.client.model.AppleReq;
|
||||
import org.openapitools.client.model.BananaReq;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -32,21 +37,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=FruitReq.FruitReqDeserializer.class)
|
||||
@JsonDeserialize(using = FruitReq.FruitReqDeserializer.class)
|
||||
@JsonSerialize(using = FruitReq.FruitReqSerializer.class)
|
||||
public class FruitReq extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(FruitReq.class.getName());
|
||||
|
||||
public static class FruitReqSerializer extends StdSerializer<FruitReq> {
|
||||
public FruitReqSerializer(Class<FruitReq> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public FruitReqSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(FruitReq value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class FruitReqDeserializer extends StdDeserializer<FruitReq> {
|
||||
public FruitReqDeserializer() {
|
||||
this(FruitReq.class);
|
||||
@@ -59,12 +87,14 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public FruitReq deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
int match = 0;
|
||||
// deserialize AppleReq
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(AppleReq.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'AppleReq'");
|
||||
} catch (Exception e) {
|
||||
@@ -75,6 +105,9 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
// deserialize BananaReq
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(BananaReq.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'BananaReq'");
|
||||
} catch (Exception e) {
|
||||
@@ -89,6 +122,15 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for FruitReq: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public FruitReq getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -113,6 +155,7 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("BananaReq", new GenericType<BananaReq>() {
|
||||
});
|
||||
JSON.registerDescendants(FruitReq.class, Collections.unmodifiableMap(schemas));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,14 +163,26 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
return FruitReq.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof AppleReq) {
|
||||
if (instance == null) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(AppleReq.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof BananaReq) {
|
||||
if (JSON.isInstanceOf(BananaReq.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,8 @@ import java.math.BigDecimal;
|
||||
import org.openapitools.client.model.Apple;
|
||||
import org.openapitools.client.model.Banana;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -32,21 +36,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=GmFruit.GmFruitDeserializer.class)
|
||||
@JsonSerialize(using = GmFruit.GmFruitSerializer.class)
|
||||
public class GmFruit extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(GmFruit.class.getName());
|
||||
|
||||
public static class GmFruitSerializer extends StdSerializer<GmFruit> {
|
||||
public GmFruitSerializer(Class<GmFruit> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public GmFruitSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(GmFruit value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class GmFruitDeserializer extends StdDeserializer<GmFruit> {
|
||||
public GmFruitDeserializer() {
|
||||
this(GmFruit.class);
|
||||
@@ -85,6 +112,15 @@ public class GmFruit extends AbstractOpenApiSchema {
|
||||
|
||||
throw new IOException(String.format("Failed deserialization for GmFruit: no match found"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public GmFruit getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
throw new JsonMappingException("GmFruit cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in anyOf
|
||||
@@ -109,6 +145,7 @@ public class GmFruit extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("Banana", new GenericType<Banana>() {
|
||||
});
|
||||
JSON.registerDescendants(GmFruit.class, Collections.unmodifiableMap(schemas));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,12 +155,12 @@ public class GmFruit extends AbstractOpenApiSchema {
|
||||
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof Apple) {
|
||||
if (JSON.isInstanceOf(Apple.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Banana) {
|
||||
if (JSON.isInstanceOf(Banana.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.ChildCat;
|
||||
import org.openapitools.client.model.ParentPet;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* GrandparentAnimal
|
||||
@@ -46,7 +50,6 @@ public class GrandparentAnimal {
|
||||
|
||||
|
||||
public GrandparentAnimal petType(String petType) {
|
||||
|
||||
this.petType = petType;
|
||||
return this;
|
||||
}
|
||||
@@ -107,5 +110,13 @@ public class GrandparentAnimal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("ChildCat", ChildCat.class);
|
||||
mappings.put("ParentPet", ParentPet.class);
|
||||
mappings.put("GrandparentAnimal", GrandparentAnimal.class);
|
||||
JSON.registerDiscriminator(GrandparentAnimal.class, "pet_type", mappings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* HasOnlyReadOnly
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
|
||||
@@ -41,7 +45,6 @@ public class HealthCheckResult {
|
||||
|
||||
public HealthCheckResult nullableMessage(String nullableMessage) {
|
||||
this.nullableMessage = JsonNullable.<String>of(nullableMessage);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* InlineObject
|
||||
@@ -40,7 +44,6 @@ public class InlineObject {
|
||||
|
||||
|
||||
public InlineObject name(String name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +68,6 @@ public class InlineObject {
|
||||
|
||||
|
||||
public InlineObject status(String status) {
|
||||
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.File;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* InlineObject1
|
||||
@@ -41,7 +45,6 @@ public class InlineObject1 {
|
||||
|
||||
|
||||
public InlineObject1 additionalMetadata(String additionalMetadata) {
|
||||
|
||||
this.additionalMetadata = additionalMetadata;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class InlineObject1 {
|
||||
|
||||
|
||||
public InlineObject1 file(File file) {
|
||||
|
||||
this.file = file;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* InlineObject2
|
||||
@@ -114,7 +118,6 @@ public class InlineObject2 {
|
||||
|
||||
|
||||
public InlineObject2 enumFormStringArray(List<EnumFormStringArrayEnum> enumFormStringArray) {
|
||||
|
||||
this.enumFormStringArray = enumFormStringArray;
|
||||
return this;
|
||||
}
|
||||
@@ -147,7 +150,6 @@ public class InlineObject2 {
|
||||
|
||||
|
||||
public InlineObject2 enumFormString(EnumFormStringEnum enumFormString) {
|
||||
|
||||
this.enumFormString = enumFormString;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.OffsetDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* InlineObject3
|
||||
@@ -92,7 +96,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 integer(Integer integer) {
|
||||
|
||||
this.integer = integer;
|
||||
return this;
|
||||
}
|
||||
@@ -119,7 +122,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 int32(Integer int32) {
|
||||
|
||||
this.int32 = int32;
|
||||
return this;
|
||||
}
|
||||
@@ -146,7 +148,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 int64(Long int64) {
|
||||
|
||||
this.int64 = int64;
|
||||
return this;
|
||||
}
|
||||
@@ -171,7 +172,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 number(BigDecimal number) {
|
||||
|
||||
this.number = number;
|
||||
return this;
|
||||
}
|
||||
@@ -197,7 +197,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 _float(Float _float) {
|
||||
|
||||
this._float = _float;
|
||||
return this;
|
||||
}
|
||||
@@ -223,7 +222,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 _double(Double _double) {
|
||||
|
||||
this._double = _double;
|
||||
return this;
|
||||
}
|
||||
@@ -249,7 +247,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 string(String string) {
|
||||
|
||||
this.string = string;
|
||||
return this;
|
||||
}
|
||||
@@ -274,7 +271,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 patternWithoutDelimiter(String patternWithoutDelimiter) {
|
||||
|
||||
this.patternWithoutDelimiter = patternWithoutDelimiter;
|
||||
return this;
|
||||
}
|
||||
@@ -298,7 +294,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 _byte(byte[] _byte) {
|
||||
|
||||
this._byte = _byte;
|
||||
return this;
|
||||
}
|
||||
@@ -322,7 +317,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 binary(File binary) {
|
||||
|
||||
this.binary = binary;
|
||||
return this;
|
||||
}
|
||||
@@ -347,7 +341,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 date(LocalDate date) {
|
||||
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
@@ -372,7 +365,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 dateTime(OffsetDateTime dateTime) {
|
||||
|
||||
this.dateTime = dateTime;
|
||||
return this;
|
||||
}
|
||||
@@ -397,7 +389,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 password(String password) {
|
||||
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
@@ -422,7 +413,6 @@ public class InlineObject3 {
|
||||
|
||||
|
||||
public InlineObject3 callback(String callback) {
|
||||
|
||||
this.callback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* InlineObject4
|
||||
@@ -40,7 +44,6 @@ public class InlineObject4 {
|
||||
|
||||
|
||||
public InlineObject4 param(String param) {
|
||||
|
||||
this.param = param;
|
||||
return this;
|
||||
}
|
||||
@@ -64,7 +67,6 @@ public class InlineObject4 {
|
||||
|
||||
|
||||
public InlineObject4 param2(String param2) {
|
||||
|
||||
this.param2 = param2;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.File;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* InlineObject5
|
||||
@@ -41,7 +45,6 @@ public class InlineObject5 {
|
||||
|
||||
|
||||
public InlineObject5 additionalMetadata(String additionalMetadata) {
|
||||
|
||||
this.additionalMetadata = additionalMetadata;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class InlineObject5 {
|
||||
|
||||
|
||||
public InlineObject5 requiredFile(File requiredFile) {
|
||||
|
||||
this.requiredFile = requiredFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.Foo;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* InlineResponseDefault
|
||||
@@ -37,7 +41,6 @@ public class InlineResponseDefault {
|
||||
|
||||
|
||||
public InlineResponseDefault string(Foo string) {
|
||||
|
||||
this.string = string;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.ShapeInterface;
|
||||
import org.openapitools.client.model.TriangleInterface;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* IsoscelesTriangle
|
||||
@@ -42,7 +46,6 @@ public class IsoscelesTriangle {
|
||||
|
||||
|
||||
public IsoscelesTriangle shapeType(String shapeType) {
|
||||
|
||||
this.shapeType = shapeType;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class IsoscelesTriangle {
|
||||
|
||||
|
||||
public IsoscelesTriangle triangleType(String triangleType) {
|
||||
|
||||
this.triangleType = triangleType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -27,6 +29,9 @@ import org.openapitools.client.model.Pig;
|
||||
import org.openapitools.client.model.Whale;
|
||||
import org.openapitools.client.model.Zebra;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -34,21 +39,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=Mammal.MammalDeserializer.class)
|
||||
@JsonDeserialize(using = Mammal.MammalDeserializer.class)
|
||||
@JsonSerialize(using = Mammal.MammalSerializer.class)
|
||||
public class Mammal extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(Mammal.class.getName());
|
||||
|
||||
public static class MammalSerializer extends StdSerializer<Mammal> {
|
||||
public MammalSerializer(Class<Mammal> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public MammalSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Mammal value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class MammalDeserializer extends StdDeserializer<Mammal> {
|
||||
public MammalDeserializer() {
|
||||
this(Mammal.class);
|
||||
@@ -61,12 +89,34 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public Mammal deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
Object deserialized = null;
|
||||
Mammal newMammal = new Mammal();
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("className");
|
||||
switch (discriminatorValue) {
|
||||
case "Pig":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Pig.class);
|
||||
newMammal.setActualInstance(deserialized);
|
||||
return newMammal;
|
||||
case "whale":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Whale.class);
|
||||
newMammal.setActualInstance(deserialized);
|
||||
return newMammal;
|
||||
case "zebra":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Zebra.class);
|
||||
newMammal.setActualInstance(deserialized);
|
||||
return newMammal;
|
||||
default:
|
||||
log.log(Level.WARNING, String.format("Failed to lookup discriminator value `%s` for Mammal. Possible values: Pig whale zebra", discriminatorValue));
|
||||
}
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
// deserialize Pig
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Pig.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Pig'");
|
||||
} catch (Exception e) {
|
||||
@@ -77,6 +127,9 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
// deserialize Whale
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Whale.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Whale'");
|
||||
} catch (Exception e) {
|
||||
@@ -87,6 +140,9 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
// deserialize Zebra
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Zebra.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Zebra'");
|
||||
} catch (Exception e) {
|
||||
@@ -101,6 +157,15 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for Mammal: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public Mammal getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
throw new JsonMappingException("Mammal cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -132,6 +197,14 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("Zebra", new GenericType<Zebra>() {
|
||||
});
|
||||
JSON.registerDescendants(Mammal.class, Collections.unmodifiableMap(schemas));
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("Pig", Pig.class);
|
||||
mappings.put("whale", Whale.class);
|
||||
mappings.put("zebra", Zebra.class);
|
||||
mappings.put("mammal", Mammal.class);
|
||||
JSON.registerDiscriminator(Mammal.class, "className", mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,19 +212,26 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
return Mammal.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof Pig) {
|
||||
if (JSON.isInstanceOf(Pig.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Whale) {
|
||||
if (JSON.isInstanceOf(Whale.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Zebra) {
|
||||
if (JSON.isInstanceOf(Zebra.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* MapTest
|
||||
@@ -86,7 +90,6 @@ public class MapTest {
|
||||
|
||||
|
||||
public MapTest mapMapOfString(Map<String, Map<String, String>> mapMapOfString) {
|
||||
|
||||
this.mapMapOfString = mapMapOfString;
|
||||
return this;
|
||||
}
|
||||
@@ -119,7 +122,6 @@ public class MapTest {
|
||||
|
||||
|
||||
public MapTest mapOfEnumString(Map<String, InnerEnum> mapOfEnumString) {
|
||||
|
||||
this.mapOfEnumString = mapOfEnumString;
|
||||
return this;
|
||||
}
|
||||
@@ -152,7 +154,6 @@ public class MapTest {
|
||||
|
||||
|
||||
public MapTest directMap(Map<String, Boolean> directMap) {
|
||||
|
||||
this.directMap = directMap;
|
||||
return this;
|
||||
}
|
||||
@@ -185,7 +186,6 @@ public class MapTest {
|
||||
|
||||
|
||||
public MapTest indirectMap(Map<String, Boolean> indirectMap) {
|
||||
|
||||
this.indirectMap = indirectMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -28,6 +30,8 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* MixedPropertiesAndAdditionalPropertiesClass
|
||||
@@ -50,7 +54,6 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) {
|
||||
|
||||
this.uuid = uuid;
|
||||
return this;
|
||||
}
|
||||
@@ -75,7 +78,6 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass dateTime(OffsetDateTime dateTime) {
|
||||
|
||||
this.dateTime = dateTime;
|
||||
return this;
|
||||
}
|
||||
@@ -100,7 +102,6 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
|
||||
|
||||
public MixedPropertiesAndAdditionalPropertiesClass map(Map<String, Animal> map) {
|
||||
|
||||
this.map = map;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing model name starting with number
|
||||
@@ -41,7 +45,6 @@ public class Model200Response {
|
||||
|
||||
|
||||
public Model200Response name(Integer name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class Model200Response {
|
||||
|
||||
|
||||
public Model200Response propertyClass(String propertyClass) {
|
||||
|
||||
this.propertyClass = propertyClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ModelApiResponse
|
||||
@@ -44,7 +48,6 @@ public class ModelApiResponse {
|
||||
|
||||
|
||||
public ModelApiResponse code(Integer code) {
|
||||
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
@@ -69,7 +72,6 @@ public class ModelApiResponse {
|
||||
|
||||
|
||||
public ModelApiResponse type(String type) {
|
||||
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
@@ -94,7 +96,6 @@ public class ModelApiResponse {
|
||||
|
||||
|
||||
public ModelApiResponse message(String message) {
|
||||
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing reserved words
|
||||
@@ -37,7 +41,6 @@ public class ModelReturn {
|
||||
|
||||
|
||||
public ModelReturn _return(Integer _return) {
|
||||
|
||||
this._return = _return;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing model name same as property name
|
||||
@@ -49,7 +53,6 @@ public class Name {
|
||||
|
||||
|
||||
public Name name(Integer name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -89,7 +92,6 @@ public class Name {
|
||||
|
||||
|
||||
public Name property(String property) {
|
||||
|
||||
this.property = property;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,14 @@
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -32,6 +38,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* NullableClass
|
||||
@@ -51,7 +59,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
NullableClass.JSON_PROPERTY_OBJECT_ITEMS_NULLABLE
|
||||
})
|
||||
|
||||
public class NullableClass extends HashMap<String, Object> {
|
||||
public class NullableClass {
|
||||
public static final String JSON_PROPERTY_INTEGER_PROP = "integer_prop";
|
||||
private JsonNullable<Integer> integerProp = JsonNullable.<Integer>undefined();
|
||||
|
||||
@@ -91,7 +99,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass integerProp(Integer integerProp) {
|
||||
this.integerProp = JsonNullable.<Integer>of(integerProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -126,7 +133,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass numberProp(BigDecimal numberProp) {
|
||||
this.numberProp = JsonNullable.<BigDecimal>of(numberProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -161,7 +167,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass booleanProp(Boolean booleanProp) {
|
||||
this.booleanProp = JsonNullable.<Boolean>of(booleanProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -196,7 +201,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass stringProp(String stringProp) {
|
||||
this.stringProp = JsonNullable.<String>of(stringProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -231,7 +235,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass dateProp(LocalDate dateProp) {
|
||||
this.dateProp = JsonNullable.<LocalDate>of(dateProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -266,7 +269,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass datetimeProp(OffsetDateTime datetimeProp) {
|
||||
this.datetimeProp = JsonNullable.<OffsetDateTime>of(datetimeProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -301,7 +303,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass arrayNullableProp(List<Object> arrayNullableProp) {
|
||||
this.arrayNullableProp = JsonNullable.<List<Object>>of(arrayNullableProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -348,7 +349,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass arrayAndItemsNullableProp(List<Object> arrayAndItemsNullableProp) {
|
||||
this.arrayAndItemsNullableProp = JsonNullable.<List<Object>>of(arrayAndItemsNullableProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -394,7 +394,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
|
||||
public NullableClass arrayItemsNullable(List<Object> arrayItemsNullable) {
|
||||
|
||||
this.arrayItemsNullable = arrayItemsNullable;
|
||||
return this;
|
||||
}
|
||||
@@ -428,7 +427,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass objectNullableProp(Map<String, Object> objectNullableProp) {
|
||||
this.objectNullableProp = JsonNullable.<Map<String, Object>>of(objectNullableProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -475,7 +473,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
public NullableClass objectAndItemsNullableProp(Map<String, Object> objectAndItemsNullableProp) {
|
||||
this.objectAndItemsNullableProp = JsonNullable.<Map<String, Object>>of(objectAndItemsNullableProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -521,7 +518,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
|
||||
|
||||
public NullableClass objectItemsNullable(Map<String, Object> objectItemsNullable) {
|
||||
|
||||
this.objectItemsNullable = objectItemsNullable;
|
||||
return this;
|
||||
}
|
||||
@@ -552,6 +548,43 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
this.objectItemsNullable = objectItemsNullable;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public NullableClass putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*/
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
@@ -573,13 +606,13 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
Objects.equals(this.arrayItemsNullable, nullableClass.arrayItemsNullable) &&
|
||||
Objects.equals(this.objectNullableProp, nullableClass.objectNullableProp) &&
|
||||
Objects.equals(this.objectAndItemsNullableProp, nullableClass.objectAndItemsNullableProp) &&
|
||||
Objects.equals(this.objectItemsNullable, nullableClass.objectItemsNullable) &&
|
||||
super.equals(o);
|
||||
Objects.equals(this.objectItemsNullable, nullableClass.objectItemsNullable)&&
|
||||
Objects.equals(this.additionalProperties, nullableClass.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(integerProp, numberProp, booleanProp, stringProp, dateProp, datetimeProp, arrayNullableProp, arrayAndItemsNullableProp, arrayItemsNullable, objectNullableProp, objectAndItemsNullableProp, objectItemsNullable, super.hashCode());
|
||||
return Objects.hash(integerProp, numberProp, booleanProp, stringProp, dateProp, datetimeProp, arrayNullableProp, arrayAndItemsNullableProp, arrayItemsNullable, objectNullableProp, objectAndItemsNullableProp, objectItemsNullable, additionalProperties);
|
||||
}
|
||||
|
||||
|
||||
@@ -587,7 +620,6 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class NullableClass {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" integerProp: ").append(toIndentedString(integerProp)).append("\n");
|
||||
sb.append(" numberProp: ").append(toIndentedString(numberProp)).append("\n");
|
||||
sb.append(" booleanProp: ").append(toIndentedString(booleanProp)).append("\n");
|
||||
@@ -600,6 +632,7 @@ public class NullableClass extends HashMap<String, Object> {
|
||||
sb.append(" objectNullableProp: ").append(toIndentedString(objectNullableProp)).append("\n");
|
||||
sb.append(" objectAndItemsNullableProp: ").append(toIndentedString(objectAndItemsNullableProp)).append("\n");
|
||||
sb.append(" objectItemsNullable: ").append(toIndentedString(objectItemsNullable)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.Quadrilateral;
|
||||
import org.openapitools.client.model.Triangle;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -33,21 +38,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=NullableShape.NullableShapeDeserializer.class)
|
||||
@JsonDeserialize(using = NullableShape.NullableShapeDeserializer.class)
|
||||
@JsonSerialize(using = NullableShape.NullableShapeSerializer.class)
|
||||
public class NullableShape extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(NullableShape.class.getName());
|
||||
|
||||
public static class NullableShapeSerializer extends StdSerializer<NullableShape> {
|
||||
public NullableShapeSerializer(Class<NullableShape> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public NullableShapeSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(NullableShape value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class NullableShapeDeserializer extends StdDeserializer<NullableShape> {
|
||||
public NullableShapeDeserializer() {
|
||||
this(NullableShape.class);
|
||||
@@ -60,12 +88,30 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public NullableShape deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
Object deserialized = null;
|
||||
NullableShape newNullableShape = new NullableShape();
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("shapeType");
|
||||
switch (discriminatorValue) {
|
||||
case "Quadrilateral":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Quadrilateral.class);
|
||||
newNullableShape.setActualInstance(deserialized);
|
||||
return newNullableShape;
|
||||
case "Triangle":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
newNullableShape.setActualInstance(deserialized);
|
||||
return newNullableShape;
|
||||
default:
|
||||
log.log(Level.WARNING, String.format("Failed to lookup discriminator value `%s` for NullableShape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
}
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Quadrilateral.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Quadrilateral'");
|
||||
} catch (Exception e) {
|
||||
@@ -76,6 +122,9 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
// deserialize Triangle
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Triangle'");
|
||||
} catch (Exception e) {
|
||||
@@ -90,6 +139,15 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for NullableShape: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public NullableShape getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -114,6 +172,13 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("Triangle", new GenericType<Triangle>() {
|
||||
});
|
||||
JSON.registerDescendants(NullableShape.class, Collections.unmodifiableMap(schemas));
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("Quadrilateral", Quadrilateral.class);
|
||||
mappings.put("Triangle", Triangle.class);
|
||||
mappings.put("NullableShape", NullableShape.class);
|
||||
JSON.registerDiscriminator(NullableShape.class, "shapeType", mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,14 +186,26 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
return NullableShape.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof Quadrilateral) {
|
||||
if (instance == null) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Triangle) {
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* NumberOnly
|
||||
@@ -37,7 +41,6 @@ public class NumberOnly {
|
||||
|
||||
|
||||
public NumberOnly justNumber(BigDecimal justNumber) {
|
||||
|
||||
this.justNumber = justNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.time.OffsetDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Order
|
||||
@@ -94,7 +98,6 @@ public class Order {
|
||||
|
||||
|
||||
public Order id(Long id) {
|
||||
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -119,7 +122,6 @@ public class Order {
|
||||
|
||||
|
||||
public Order petId(Long petId) {
|
||||
|
||||
this.petId = petId;
|
||||
return this;
|
||||
}
|
||||
@@ -144,7 +146,6 @@ public class Order {
|
||||
|
||||
|
||||
public Order quantity(Integer quantity) {
|
||||
|
||||
this.quantity = quantity;
|
||||
return this;
|
||||
}
|
||||
@@ -169,7 +170,6 @@ public class Order {
|
||||
|
||||
|
||||
public Order shipDate(OffsetDateTime shipDate) {
|
||||
|
||||
this.shipDate = shipDate;
|
||||
return this;
|
||||
}
|
||||
@@ -194,7 +194,6 @@ public class Order {
|
||||
|
||||
|
||||
public Order status(StatusEnum status) {
|
||||
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
@@ -219,7 +218,6 @@ public class Order {
|
||||
|
||||
|
||||
public Order complete(Boolean complete) {
|
||||
|
||||
this.complete = complete;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -23,6 +25,8 @@ import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* OuterComposite
|
||||
@@ -45,7 +49,6 @@ public class OuterComposite {
|
||||
|
||||
|
||||
public OuterComposite myNumber(BigDecimal myNumber) {
|
||||
|
||||
this.myNumber = myNumber;
|
||||
return this;
|
||||
}
|
||||
@@ -70,7 +73,6 @@ public class OuterComposite {
|
||||
|
||||
|
||||
public OuterComposite myString(String myString) {
|
||||
|
||||
this.myString = myString;
|
||||
return this;
|
||||
}
|
||||
@@ -95,7 +97,6 @@ public class OuterComposite {
|
||||
|
||||
|
||||
public OuterComposite myBoolean(Boolean myBoolean) {
|
||||
|
||||
this.myBoolean = myBoolean;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,11 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
@@ -15,7 +15,11 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
@@ -15,7 +15,11 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
@@ -15,7 +15,11 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.ChildCat;
|
||||
import org.openapitools.client.model.GrandparentAnimal;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ParentPet
|
||||
@@ -77,5 +81,12 @@ public class ParentPet extends GrandparentAnimal {
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
static {
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("ChildCat", ChildCat.class);
|
||||
mappings.put("ParentPet", ParentPet.class);
|
||||
JSON.registerDiscriminator(ParentPet.class, "pet_type", mappings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,8 @@ import java.util.List;
|
||||
import org.openapitools.client.model.Category;
|
||||
import org.openapitools.client.model.Tag;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Pet
|
||||
@@ -97,7 +101,6 @@ public class Pet {
|
||||
|
||||
|
||||
public Pet id(Long id) {
|
||||
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -122,7 +125,6 @@ public class Pet {
|
||||
|
||||
|
||||
public Pet category(Category category) {
|
||||
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
@@ -147,7 +149,6 @@ public class Pet {
|
||||
|
||||
|
||||
public Pet name(String name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -171,7 +172,6 @@ public class Pet {
|
||||
|
||||
|
||||
public Pet photoUrls(List<String> photoUrls) {
|
||||
|
||||
this.photoUrls = photoUrls;
|
||||
return this;
|
||||
}
|
||||
@@ -200,7 +200,6 @@ public class Pet {
|
||||
|
||||
|
||||
public Pet tags(List<Tag> tags) {
|
||||
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
@@ -233,7 +232,6 @@ public class Pet {
|
||||
|
||||
|
||||
public Pet status(StatusEnum status) {
|
||||
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.BasquePig;
|
||||
import org.openapitools.client.model.DanishPig;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -33,21 +38,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=Pig.PigDeserializer.class)
|
||||
@JsonDeserialize(using = Pig.PigDeserializer.class)
|
||||
@JsonSerialize(using = Pig.PigSerializer.class)
|
||||
public class Pig extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(Pig.class.getName());
|
||||
|
||||
public static class PigSerializer extends StdSerializer<Pig> {
|
||||
public PigSerializer(Class<Pig> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public PigSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Pig value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class PigDeserializer extends StdDeserializer<Pig> {
|
||||
public PigDeserializer() {
|
||||
this(Pig.class);
|
||||
@@ -60,12 +88,30 @@ public class Pig extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public Pig deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
Object deserialized = null;
|
||||
Pig newPig = new Pig();
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("className");
|
||||
switch (discriminatorValue) {
|
||||
case "BasquePig":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(BasquePig.class);
|
||||
newPig.setActualInstance(deserialized);
|
||||
return newPig;
|
||||
case "DanishPig":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(DanishPig.class);
|
||||
newPig.setActualInstance(deserialized);
|
||||
return newPig;
|
||||
default:
|
||||
log.log(Level.WARNING, String.format("Failed to lookup discriminator value `%s` for Pig. Possible values: BasquePig DanishPig", discriminatorValue));
|
||||
}
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
// deserialize BasquePig
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(BasquePig.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'BasquePig'");
|
||||
} catch (Exception e) {
|
||||
@@ -76,6 +122,9 @@ public class Pig extends AbstractOpenApiSchema {
|
||||
// deserialize DanishPig
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(DanishPig.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'DanishPig'");
|
||||
} catch (Exception e) {
|
||||
@@ -90,6 +139,15 @@ public class Pig extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for Pig: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public Pig getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
throw new JsonMappingException("Pig cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -114,6 +172,13 @@ public class Pig extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("DanishPig", new GenericType<DanishPig>() {
|
||||
});
|
||||
JSON.registerDescendants(Pig.class, Collections.unmodifiableMap(schemas));
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("BasquePig", BasquePig.class);
|
||||
mappings.put("DanishPig", DanishPig.class);
|
||||
mappings.put("Pig", Pig.class);
|
||||
JSON.registerDiscriminator(Pig.class, "className", mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,14 +186,21 @@ public class Pig extends AbstractOpenApiSchema {
|
||||
return Pig.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof BasquePig) {
|
||||
if (JSON.isInstanceOf(BasquePig.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof DanishPig) {
|
||||
if (JSON.isInstanceOf(DanishPig.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.ComplexQuadrilateral;
|
||||
import org.openapitools.client.model.SimpleQuadrilateral;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -33,21 +38,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=Quadrilateral.QuadrilateralDeserializer.class)
|
||||
@JsonDeserialize(using = Quadrilateral.QuadrilateralDeserializer.class)
|
||||
@JsonSerialize(using = Quadrilateral.QuadrilateralSerializer.class)
|
||||
public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(Quadrilateral.class.getName());
|
||||
|
||||
public static class QuadrilateralSerializer extends StdSerializer<Quadrilateral> {
|
||||
public QuadrilateralSerializer(Class<Quadrilateral> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public QuadrilateralSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Quadrilateral value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class QuadrilateralDeserializer extends StdDeserializer<Quadrilateral> {
|
||||
public QuadrilateralDeserializer() {
|
||||
this(Quadrilateral.class);
|
||||
@@ -60,12 +88,30 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public Quadrilateral deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
Object deserialized = null;
|
||||
Quadrilateral newQuadrilateral = new Quadrilateral();
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("quadrilateralType");
|
||||
switch (discriminatorValue) {
|
||||
case "ComplexQuadrilateral":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(ComplexQuadrilateral.class);
|
||||
newQuadrilateral.setActualInstance(deserialized);
|
||||
return newQuadrilateral;
|
||||
case "SimpleQuadrilateral":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(SimpleQuadrilateral.class);
|
||||
newQuadrilateral.setActualInstance(deserialized);
|
||||
return newQuadrilateral;
|
||||
default:
|
||||
log.log(Level.WARNING, String.format("Failed to lookup discriminator value `%s` for Quadrilateral. Possible values: ComplexQuadrilateral SimpleQuadrilateral", discriminatorValue));
|
||||
}
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
// deserialize ComplexQuadrilateral
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(ComplexQuadrilateral.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'ComplexQuadrilateral'");
|
||||
} catch (Exception e) {
|
||||
@@ -76,6 +122,9 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
// deserialize SimpleQuadrilateral
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(SimpleQuadrilateral.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'SimpleQuadrilateral'");
|
||||
} catch (Exception e) {
|
||||
@@ -90,6 +139,15 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for Quadrilateral: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public Quadrilateral getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
throw new JsonMappingException("Quadrilateral cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -114,6 +172,13 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("SimpleQuadrilateral", new GenericType<SimpleQuadrilateral>() {
|
||||
});
|
||||
JSON.registerDescendants(Quadrilateral.class, Collections.unmodifiableMap(schemas));
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("ComplexQuadrilateral", ComplexQuadrilateral.class);
|
||||
mappings.put("SimpleQuadrilateral", SimpleQuadrilateral.class);
|
||||
mappings.put("Quadrilateral", Quadrilateral.class);
|
||||
JSON.registerDiscriminator(Quadrilateral.class, "quadrilateralType", mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,14 +186,21 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
return Quadrilateral.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof ComplexQuadrilateral) {
|
||||
if (JSON.isInstanceOf(ComplexQuadrilateral.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof SimpleQuadrilateral) {
|
||||
if (JSON.isInstanceOf(SimpleQuadrilateral.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* QuadrilateralInterface
|
||||
@@ -36,7 +40,6 @@ public class QuadrilateralInterface {
|
||||
|
||||
|
||||
public QuadrilateralInterface quadrilateralType(String quadrilateralType) {
|
||||
|
||||
this.quadrilateralType = quadrilateralType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ReadOnlyFirst
|
||||
@@ -56,7 +60,6 @@ public class ReadOnlyFirst {
|
||||
|
||||
|
||||
public ReadOnlyFirst baz(String baz) {
|
||||
|
||||
this.baz = baz;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.ShapeInterface;
|
||||
import org.openapitools.client.model.TriangleInterface;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ScaleneTriangle
|
||||
@@ -42,7 +46,6 @@ public class ScaleneTriangle {
|
||||
|
||||
|
||||
public ScaleneTriangle shapeType(String shapeType) {
|
||||
|
||||
this.shapeType = shapeType;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class ScaleneTriangle {
|
||||
|
||||
|
||||
public ScaleneTriangle triangleType(String triangleType) {
|
||||
|
||||
this.triangleType = triangleType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.Quadrilateral;
|
||||
import org.openapitools.client.model.Triangle;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -33,21 +38,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=Shape.ShapeDeserializer.class)
|
||||
@JsonDeserialize(using = Shape.ShapeDeserializer.class)
|
||||
@JsonSerialize(using = Shape.ShapeSerializer.class)
|
||||
public class Shape extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(Shape.class.getName());
|
||||
|
||||
public static class ShapeSerializer extends StdSerializer<Shape> {
|
||||
public ShapeSerializer(Class<Shape> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public ShapeSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Shape value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShapeDeserializer extends StdDeserializer<Shape> {
|
||||
public ShapeDeserializer() {
|
||||
this(Shape.class);
|
||||
@@ -60,12 +88,30 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public Shape deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
Object deserialized = null;
|
||||
Shape newShape = new Shape();
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("shapeType");
|
||||
switch (discriminatorValue) {
|
||||
case "Quadrilateral":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Quadrilateral.class);
|
||||
newShape.setActualInstance(deserialized);
|
||||
return newShape;
|
||||
case "Triangle":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
newShape.setActualInstance(deserialized);
|
||||
return newShape;
|
||||
default:
|
||||
log.log(Level.WARNING, String.format("Failed to lookup discriminator value `%s` for Shape. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
}
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Quadrilateral.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Quadrilateral'");
|
||||
} catch (Exception e) {
|
||||
@@ -76,6 +122,9 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
// deserialize Triangle
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Triangle'");
|
||||
} catch (Exception e) {
|
||||
@@ -90,6 +139,15 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for Shape: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public Shape getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
throw new JsonMappingException("Shape cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -114,6 +172,13 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("Triangle", new GenericType<Triangle>() {
|
||||
});
|
||||
JSON.registerDescendants(Shape.class, Collections.unmodifiableMap(schemas));
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("Quadrilateral", Quadrilateral.class);
|
||||
mappings.put("Triangle", Triangle.class);
|
||||
mappings.put("Shape", Shape.class);
|
||||
JSON.registerDiscriminator(Shape.class, "shapeType", mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,14 +186,21 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
return Shape.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof Quadrilateral) {
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Triangle) {
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* ShapeInterface
|
||||
@@ -36,7 +40,6 @@ public class ShapeInterface {
|
||||
|
||||
|
||||
public ShapeInterface shapeType(String shapeType) {
|
||||
|
||||
this.shapeType = shapeType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -26,6 +28,9 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.Quadrilateral;
|
||||
import org.openapitools.client.model.Triangle;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -33,21 +38,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=ShapeOrNull.ShapeOrNullDeserializer.class)
|
||||
@JsonDeserialize(using = ShapeOrNull.ShapeOrNullDeserializer.class)
|
||||
@JsonSerialize(using = ShapeOrNull.ShapeOrNullSerializer.class)
|
||||
public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(ShapeOrNull.class.getName());
|
||||
|
||||
public static class ShapeOrNullSerializer extends StdSerializer<ShapeOrNull> {
|
||||
public ShapeOrNullSerializer(Class<ShapeOrNull> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public ShapeOrNullSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ShapeOrNull value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShapeOrNullDeserializer extends StdDeserializer<ShapeOrNull> {
|
||||
public ShapeOrNullDeserializer() {
|
||||
this(ShapeOrNull.class);
|
||||
@@ -60,12 +88,30 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public ShapeOrNull deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
Object deserialized = null;
|
||||
ShapeOrNull newShapeOrNull = new ShapeOrNull();
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("shapeType");
|
||||
switch (discriminatorValue) {
|
||||
case "Quadrilateral":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Quadrilateral.class);
|
||||
newShapeOrNull.setActualInstance(deserialized);
|
||||
return newShapeOrNull;
|
||||
case "Triangle":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
newShapeOrNull.setActualInstance(deserialized);
|
||||
return newShapeOrNull;
|
||||
default:
|
||||
log.log(Level.WARNING, String.format("Failed to lookup discriminator value `%s` for ShapeOrNull. Possible values: Quadrilateral Triangle", discriminatorValue));
|
||||
}
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Quadrilateral.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Quadrilateral'");
|
||||
} catch (Exception e) {
|
||||
@@ -76,6 +122,9 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
// deserialize Triangle
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'Triangle'");
|
||||
} catch (Exception e) {
|
||||
@@ -90,6 +139,15 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for ShapeOrNull: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public ShapeOrNull getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -114,6 +172,13 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("Triangle", new GenericType<Triangle>() {
|
||||
});
|
||||
JSON.registerDescendants(ShapeOrNull.class, Collections.unmodifiableMap(schemas));
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("Quadrilateral", Quadrilateral.class);
|
||||
mappings.put("Triangle", Triangle.class);
|
||||
mappings.put("ShapeOrNull", ShapeOrNull.class);
|
||||
JSON.registerDiscriminator(ShapeOrNull.class, "shapeType", mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,14 +186,26 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
return ShapeOrNull.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof Quadrilateral) {
|
||||
if (instance == null) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Triangle) {
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -24,6 +26,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.model.QuadrilateralInterface;
|
||||
import org.openapitools.client.model.ShapeInterface;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* SimpleQuadrilateral
|
||||
@@ -42,7 +46,6 @@ public class SimpleQuadrilateral {
|
||||
|
||||
|
||||
public SimpleQuadrilateral shapeType(String shapeType) {
|
||||
|
||||
this.shapeType = shapeType;
|
||||
return this;
|
||||
}
|
||||
@@ -66,7 +69,6 @@ public class SimpleQuadrilateral {
|
||||
|
||||
|
||||
public SimpleQuadrilateral quadrilateralType(String quadrilateralType) {
|
||||
|
||||
this.quadrilateralType = quadrilateralType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* SpecialModelName
|
||||
@@ -36,7 +40,6 @@ public class SpecialModelName {
|
||||
|
||||
|
||||
public SpecialModelName $specialPropertyName(Long $specialPropertyName) {
|
||||
|
||||
this.$specialPropertyName = $specialPropertyName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Tag
|
||||
@@ -40,7 +44,6 @@ public class Tag {
|
||||
|
||||
|
||||
public Tag id(Long id) {
|
||||
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +68,6 @@ public class Tag {
|
||||
|
||||
|
||||
public Tag name(String name) {
|
||||
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -27,6 +29,9 @@ import org.openapitools.client.model.EquilateralTriangle;
|
||||
import org.openapitools.client.model.IsoscelesTriangle;
|
||||
import org.openapitools.client.model.ScaleneTriangle;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
import javax.ws.rs.core.GenericType;
|
||||
import javax.ws.rs.core.Response;
|
||||
@@ -34,21 +39,44 @@ import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
@JsonDeserialize(using=Triangle.TriangleDeserializer.class)
|
||||
@JsonDeserialize(using = Triangle.TriangleDeserializer.class)
|
||||
@JsonSerialize(using = Triangle.TriangleSerializer.class)
|
||||
public class Triangle extends AbstractOpenApiSchema {
|
||||
private static final Logger log = Logger.getLogger(Triangle.class.getName());
|
||||
|
||||
public static class TriangleSerializer extends StdSerializer<Triangle> {
|
||||
public TriangleSerializer(Class<Triangle> t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public TriangleSerializer() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(Triangle value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeObject(value.getActualInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public static class TriangleDeserializer extends StdDeserializer<Triangle> {
|
||||
public TriangleDeserializer() {
|
||||
this(Triangle.class);
|
||||
@@ -61,12 +89,34 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
@Override
|
||||
public Triangle deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode tree = jp.readValueAsTree();
|
||||
Object deserialized = null;
|
||||
Triangle newTriangle = new Triangle();
|
||||
Map<String,Object> result2 = tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Map<String, Object>>() {});
|
||||
String discriminatorValue = (String)result2.get("triangleType");
|
||||
switch (discriminatorValue) {
|
||||
case "EquilateralTriangle":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(EquilateralTriangle.class);
|
||||
newTriangle.setActualInstance(deserialized);
|
||||
return newTriangle;
|
||||
case "IsoscelesTriangle":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(IsoscelesTriangle.class);
|
||||
newTriangle.setActualInstance(deserialized);
|
||||
return newTriangle;
|
||||
case "ScaleneTriangle":
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(ScaleneTriangle.class);
|
||||
newTriangle.setActualInstance(deserialized);
|
||||
return newTriangle;
|
||||
default:
|
||||
log.log(Level.WARNING, String.format("Failed to lookup discriminator value `%s` for Triangle. Possible values: EquilateralTriangle IsoscelesTriangle ScaleneTriangle", discriminatorValue));
|
||||
}
|
||||
|
||||
int match = 0;
|
||||
Object deserialized = null;
|
||||
// deserialize EquilateralTriangle
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(EquilateralTriangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'EquilateralTriangle'");
|
||||
} catch (Exception e) {
|
||||
@@ -77,6 +127,9 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
// deserialize IsoscelesTriangle
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(IsoscelesTriangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'IsoscelesTriangle'");
|
||||
} catch (Exception e) {
|
||||
@@ -87,6 +140,9 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
// deserialize ScaleneTriangle
|
||||
try {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(ScaleneTriangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
// (min, max, enum, pattern...), this does not perform a strict JSON
|
||||
// validation, which means the 'match' count may be higher than it should be.
|
||||
match++;
|
||||
log.log(Level.FINER, "Input data matches schema 'ScaleneTriangle'");
|
||||
} catch (Exception e) {
|
||||
@@ -101,6 +157,15 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
}
|
||||
throw new IOException(String.format("Failed deserialization for Triangle: %d classes match result, expected 1", match));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle deserialization of the 'null' value.
|
||||
*/
|
||||
@Override
|
||||
public Triangle getNullValue(DeserializationContext ctxt) throws JsonMappingException {
|
||||
throw new JsonMappingException("Triangle cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
// store a list of schema names defined in oneOf
|
||||
@@ -132,6 +197,14 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
});
|
||||
schemas.put("ScaleneTriangle", new GenericType<ScaleneTriangle>() {
|
||||
});
|
||||
JSON.registerDescendants(Triangle.class, Collections.unmodifiableMap(schemas));
|
||||
// Initialize and register the discriminator mappings.
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("EquilateralTriangle", EquilateralTriangle.class);
|
||||
mappings.put("IsoscelesTriangle", IsoscelesTriangle.class);
|
||||
mappings.put("ScaleneTriangle", ScaleneTriangle.class);
|
||||
mappings.put("Triangle", Triangle.class);
|
||||
JSON.registerDiscriminator(Triangle.class, "triangleType", mappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,19 +212,26 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
return Triangle.schemas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the instance that matches the oneOf child schema, check
|
||||
* the instance parameter is valid against the oneOf child schemas.
|
||||
*
|
||||
* It could be an instance of the 'oneOf' schemas.
|
||||
* The oneOf child schemas may themselves be a composed schema (allOf, anyOf, oneOf).
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (instance instanceof EquilateralTriangle) {
|
||||
if (JSON.isInstanceOf(EquilateralTriangle.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof IsoscelesTriangle) {
|
||||
if (JSON.isInstanceOf(IsoscelesTriangle.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof ScaleneTriangle) {
|
||||
if (JSON.isInstanceOf(ScaleneTriangle.class, instance, new HashSet<Class>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* TriangleInterface
|
||||
@@ -36,7 +40,6 @@ public class TriangleInterface {
|
||||
|
||||
|
||||
public TriangleInterface triangleType(String triangleType) {
|
||||
|
||||
this.triangleType = triangleType;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -25,6 +27,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.util.NoSuchElementException;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* User
|
||||
@@ -83,7 +87,6 @@ public class User {
|
||||
|
||||
|
||||
public User id(Long id) {
|
||||
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -108,7 +111,6 @@ public class User {
|
||||
|
||||
|
||||
public User username(String username) {
|
||||
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
@@ -133,7 +135,6 @@ public class User {
|
||||
|
||||
|
||||
public User firstName(String firstName) {
|
||||
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
@@ -158,7 +159,6 @@ public class User {
|
||||
|
||||
|
||||
public User lastName(String lastName) {
|
||||
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
@@ -183,7 +183,6 @@ public class User {
|
||||
|
||||
|
||||
public User email(String email) {
|
||||
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
@@ -208,7 +207,6 @@ public class User {
|
||||
|
||||
|
||||
public User password(String password) {
|
||||
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
@@ -233,7 +231,6 @@ public class User {
|
||||
|
||||
|
||||
public User phone(String phone) {
|
||||
|
||||
this.phone = phone;
|
||||
return this;
|
||||
}
|
||||
@@ -258,7 +255,6 @@ public class User {
|
||||
|
||||
|
||||
public User userStatus(Integer userStatus) {
|
||||
|
||||
this.userStatus = userStatus;
|
||||
return this;
|
||||
}
|
||||
@@ -283,7 +279,6 @@ public class User {
|
||||
|
||||
|
||||
public User objectWithNoDeclaredProps(Object objectWithNoDeclaredProps) {
|
||||
|
||||
this.objectWithNoDeclaredProps = objectWithNoDeclaredProps;
|
||||
return this;
|
||||
}
|
||||
@@ -309,7 +304,6 @@ public class User {
|
||||
|
||||
public User objectWithNoDeclaredPropsNullable(Object objectWithNoDeclaredPropsNullable) {
|
||||
this.objectWithNoDeclaredPropsNullable = JsonNullable.<Object>of(objectWithNoDeclaredPropsNullable);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -344,7 +338,6 @@ public class User {
|
||||
|
||||
public User anyTypeProp(Object anyTypeProp) {
|
||||
this.anyTypeProp = JsonNullable.<Object>of(anyTypeProp);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -379,7 +372,6 @@ public class User {
|
||||
|
||||
public User anyTypePropNullable(Object anyTypePropNullable) {
|
||||
this.anyTypePropNullable = JsonNullable.<Object>of(anyTypePropNullable);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ package org.openapitools.client.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
@@ -22,6 +24,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Whale
|
||||
@@ -44,7 +48,6 @@ public class Whale {
|
||||
|
||||
|
||||
public Whale hasBaleen(Boolean hasBaleen) {
|
||||
|
||||
this.hasBaleen = hasBaleen;
|
||||
return this;
|
||||
}
|
||||
@@ -69,7 +72,6 @@ public class Whale {
|
||||
|
||||
|
||||
public Whale hasTeeth(Boolean hasTeeth) {
|
||||
|
||||
this.hasTeeth = hasTeeth;
|
||||
return this;
|
||||
}
|
||||
@@ -94,7 +96,6 @@ public class Whale {
|
||||
|
||||
|
||||
public Whale className(String className) {
|
||||
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -13,17 +13,23 @@
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
|
||||
/**
|
||||
* Zebra
|
||||
@@ -33,7 +39,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
Zebra.JSON_PROPERTY_CLASS_NAME
|
||||
})
|
||||
|
||||
public class Zebra extends HashMap<String, Object> {
|
||||
public class Zebra {
|
||||
/**
|
||||
* Gets or Sets type
|
||||
*/
|
||||
@@ -79,7 +85,6 @@ public class Zebra extends HashMap<String, Object> {
|
||||
|
||||
|
||||
public Zebra type(TypeEnum type) {
|
||||
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
@@ -104,7 +109,6 @@ public class Zebra extends HashMap<String, Object> {
|
||||
|
||||
|
||||
public Zebra className(String className) {
|
||||
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
@@ -126,6 +130,43 @@ public class Zebra extends HashMap<String, Object> {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public Zebra putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*/
|
||||
@JsonAnyGetter
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
@@ -137,13 +178,13 @@ public class Zebra extends HashMap<String, Object> {
|
||||
}
|
||||
Zebra zebra = (Zebra) o;
|
||||
return Objects.equals(this.type, zebra.type) &&
|
||||
Objects.equals(this.className, zebra.className) &&
|
||||
super.equals(o);
|
||||
Objects.equals(this.className, zebra.className)&&
|
||||
Objects.equals(this.additionalProperties, zebra.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(type, className, super.hashCode());
|
||||
return Objects.hash(type, className, additionalProperties);
|
||||
}
|
||||
|
||||
|
||||
@@ -151,9 +192,9 @@ public class Zebra extends HashMap<String, Object> {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Zebra {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" type: ").append(toIndentedString(type)).append("\n");
|
||||
sb.append(" className: ").append(toIndentedString(className)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
package org.openapitools.client;
|
||||
|
||||
import org.openapitools.client.model.Mammal;
|
||||
import org.openapitools.client.model.AppleReq;
|
||||
import org.openapitools.client.model.BananaReq;
|
||||
import org.openapitools.client.model.FruitReq;
|
||||
import org.openapitools.client.model.BasquePig;
|
||||
import org.openapitools.client.model.Pig;
|
||||
import org.openapitools.client.model.Whale;
|
||||
import org.openapitools.client.model.Zebra;
|
||||
import org.openapitools.client.model.*;
|
||||
import java.lang.Exception;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -16,12 +10,10 @@ import static org.junit.Assert.*;
|
||||
|
||||
public class JSONComposedSchemaTest {
|
||||
JSON json = null;
|
||||
Mammal mammal = null;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
json = new JSON();
|
||||
mammal = new Mammal();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,9 +24,49 @@ public class JSONComposedSchemaTest {
|
||||
public void testOneOfSchemaWithoutDiscriminator() throws Exception {
|
||||
// BananaReq and AppleReq have explicitly defined properties that are different by name.
|
||||
// There is no discriminator property.
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"mealy\": false }";
|
||||
FruitReq o = json.getContext(null).readValue(str, FruitReq.class);
|
||||
assertTrue(o.getActualInstance() instanceof AppleReq);
|
||||
{
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"mealy\": false }";
|
||||
FruitReq o = json.getContext(null).readValue(str, FruitReq.class);
|
||||
assertTrue(o.getActualInstance() instanceof AppleReq);
|
||||
AppleReq inst = (AppleReq) o.getActualInstance();
|
||||
assertEquals(inst.getCultivar(), "golden delicious");
|
||||
assertEquals(inst.getMealy(), false);
|
||||
}
|
||||
{
|
||||
// Same test, but this time with additional (undeclared) properties.
|
||||
// Since FruitReq has additionalProperties: false, deserialization should fail.
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"mealy\": false, \"garbage_prop\": \"abc\" }";
|
||||
Exception exception = assertThrows(JsonMappingException.class, () -> {
|
||||
FruitReq o = json.getContext(null).readValue(str, FruitReq.class);
|
||||
});
|
||||
assertTrue(exception.getMessage().contains("Failed deserialization for FruitReq: 0 classes match result"));
|
||||
}
|
||||
{
|
||||
String str = "{ \"lengthCm\": 17 }";
|
||||
FruitReq o = json.getContext(null).readValue(str, FruitReq.class);
|
||||
assertTrue(o.getActualInstance() instanceof BananaReq);
|
||||
BananaReq inst = (BananaReq) o.getActualInstance();
|
||||
assertEquals(inst.getLengthCm(), new java.math.BigDecimal(17));
|
||||
}
|
||||
{
|
||||
// Try to deserialize empty object. This should fail 'oneOf' because that will match
|
||||
// both AppleReq and BananaReq.
|
||||
String str = "{ }";
|
||||
Exception exception = assertThrows(JsonMappingException.class, () -> {
|
||||
json.getContext(null).readValue(str, FruitReq.class);
|
||||
});
|
||||
assertTrue(exception.getMessage().contains("Failed deserialization for FruitReq: 2 classes match result"));
|
||||
// TODO: add a similar unit test where the oneOf child schemas have required properties.
|
||||
// If the implementation is correct, the unmarshaling should take the "required" keyword
|
||||
// into consideration, which it is not doing currently.
|
||||
}
|
||||
{
|
||||
// Deserialize the null value. This should be allowed because the 'FruitReq' schema
|
||||
// has nullable: true.
|
||||
String str = "null";
|
||||
FruitReq o = json.getContext(null).readValue(str, FruitReq.class);
|
||||
assertNull(o);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,24 +77,247 @@ public class JSONComposedSchemaTest {
|
||||
public void testOneOfSchemaWithDiscriminator() throws Exception {
|
||||
// Mammal can be one of whale, pig and zebra.
|
||||
// pig has sub-classes.
|
||||
String str = "{ \"className\": \"whale\", \"hasBaleen\": true, \"hasTeeth\": false }";
|
||||
/*
|
||||
DISABLING unit test for now until ambiguity of discriminator is resolved.
|
||||
|
||||
// Note that the 'zebra' schema does not have any explicit property defined AND
|
||||
// it has additionalProperties: true. Hence without a discriminator the above
|
||||
// JSON payload would match both 'whale' and 'zebra'. This is because the 'hasBaleen'
|
||||
// and 'hasTeeth' would be considered additional (undeclared) properties for 'zebra'.
|
||||
Mammal o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertTrue(o.getActualInstance() instanceof Whale);
|
||||
{
|
||||
String str = "{ \"className\": \"whale\", \"hasBaleen\": true, \"hasTeeth\": false }";
|
||||
|
||||
// Note that the 'zebra' schema does not have any explicit property defined AND
|
||||
// it has additionalProperties: true. Hence without a discriminator the above
|
||||
// JSON payload would match both 'whale' and 'zebra'. This is because the 'hasBaleen'
|
||||
// and 'hasTeeth' would be considered additional (undeclared) properties for 'zebra'.
|
||||
AbstractOpenApiSchema o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertNotNull(o);
|
||||
assertTrue(o.getActualInstance() instanceof Whale);
|
||||
}
|
||||
{
|
||||
String str = "{ \"className\": \"zebra\", \"type\": \"plains\" }";
|
||||
AbstractOpenApiSchema o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertNotNull(o);
|
||||
assertTrue(o.getActualInstance() instanceof Zebra);
|
||||
Zebra z = (Zebra)o.getActualInstance();
|
||||
assertEquals(Zebra.TypeEnum.PLAINS, z.getType());
|
||||
}
|
||||
{
|
||||
// The discriminator value is valid but the 'type' value is invalid.
|
||||
String str = "{ \"className\": \"zebra\", \"type\": \"garbage_value\" }";
|
||||
Exception exception = assertThrows(JsonMappingException.class, () -> {
|
||||
json.getContext(null).readValue(str, Mammal.class);
|
||||
});
|
||||
}
|
||||
{
|
||||
// The discriminator value is zebra but the properties belong to Whale.
|
||||
// The 'whale' properties are considered to be additional (undeclared) properties
|
||||
// because in the 'zebra' schema, the 'additionalProperties' keyword has been set
|
||||
// to true.
|
||||
// TODO: The outcome should depend on the value of the 'useOneOfDiscriminatorLookup' CLI.
|
||||
String str = "{ \"className\": \"zebra\", \"hasBaleen\": true, \"hasTeeth\": false }";
|
||||
AbstractOpenApiSchema o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertNotNull(o);
|
||||
assertTrue(o.getActualInstance() instanceof Zebra);
|
||||
}
|
||||
{
|
||||
String str = "{ \"className\": \"zebra\" }";
|
||||
AbstractOpenApiSchema o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertNotNull(o);
|
||||
assertTrue(o.getActualInstance() instanceof Zebra);
|
||||
}
|
||||
{
|
||||
/* comment out while unboxing nested oneOf/anyOf is still in discussion
|
||||
// Deserialization test with indirections of 'oneOf' child schemas.
|
||||
// Mammal is oneOf whale, zebra and pig, and pig is itself one of BasquePig, DanishPig.
|
||||
String str = "{ \"className\": \"BasquePig\" }";
|
||||
AbstractOpenApiSchema o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertTrue(o.getActualInstance() instanceof BasquePig);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
str = "{ \"className\": \"zebra\" }";
|
||||
o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertTrue(o.getActualInstance() instanceof Zebra);
|
||||
@Test
|
||||
public void testOneOfNullable() throws Exception {
|
||||
String str = "null";
|
||||
// 'null' is a valid value for NullableShape because it is nullable.
|
||||
AbstractOpenApiSchema o = json.getContext(null).readValue(str, NullableShape.class);
|
||||
assertNull(o);
|
||||
|
||||
str = "{ \"className\": \"BasquePig\" }";
|
||||
o = json.getContext(null).readValue(str, Mammal.class);
|
||||
assertTrue(o.getActualInstance() instanceof BasquePig);
|
||||
// 'null' is a valid value for ShapeOrNull because it is a oneOf with one of the
|
||||
// children being the null type.
|
||||
o = json.getContext(null).readValue(str, ShapeOrNull.class);
|
||||
assertNull(o);
|
||||
|
||||
// 'null' is not a valid value for the Shape model because it is not nullable.
|
||||
// An exception should be raised.
|
||||
Exception exception = assertThrows(JsonMappingException.class, () -> {
|
||||
json.getContext(null).readValue(str, Shape.class);
|
||||
});
|
||||
assertEquals("Shape cannot be null", exception.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test payload with more than one discriminator.
|
||||
*/
|
||||
@Test
|
||||
public void testOneOfMultipleDiscriminators() throws Exception {
|
||||
// 'shapeType' is a discriminator for the 'Shape' model and
|
||||
// 'triangleType' is a discriminator forr the 'Triangle' model.
|
||||
String str = "{ \"shapeType\": \"Triangle\", \"triangleType\": \"EquilateralTriangle\" }";
|
||||
|
||||
// We should be able to deserialize a equilateral triangle into a EquilateralTriangle class.
|
||||
EquilateralTriangle t = json.getContext(null).readValue(str, EquilateralTriangle.class);
|
||||
assertNotNull(t);
|
||||
|
||||
// We should be able to deserialize a equilateral triangle into a triangle.
|
||||
AbstractOpenApiSchema o = json.getContext(null).readValue(str, Triangle.class);
|
||||
assertNotNull(o);
|
||||
assertTrue(o.getActualInstance() instanceof EquilateralTriangle);
|
||||
|
||||
// We should be able to deserialize a equilateral triangle into a shape.
|
||||
o = json.getContext(null).readValue(str, Shape.class);
|
||||
// The container is a shape, and the actual instance should be a EquilateralTriangle.
|
||||
assertTrue(o instanceof Shape);
|
||||
/* comment out while unboxing nested oneOf/anyOf is still in discussion
|
||||
assertTrue(o.getActualInstance() instanceof EquilateralTriangle);
|
||||
|
||||
// It is not valid to deserialize a equilateral triangle into a quadrilateral.
|
||||
Exception exception = assertThrows(JsonMappingException.class, () -> {
|
||||
json.getContext(null).readValue(str, Quadrilateral.class);
|
||||
});
|
||||
assertTrue(exception.getMessage().contains("Failed deserialization for Quadrilateral: 0 classes match result"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneOfNestedComposedSchema() throws Exception {
|
||||
/*
|
||||
{
|
||||
String str = "{ " +
|
||||
" \"mainShape\": { \"shapeType\": \"Triangle\", \"triangleType\": \"EquilateralTriangle\" }, " +
|
||||
" \"shapeOrNull\": { \"shapeType\": \"Triangle\", \"triangleType\": \"IsoscelesTriangle\" }, " +
|
||||
" \"nullableShape\": { \"shapeType\": \"Triangle\", \"triangleType\": \"ScaleneTriangle\" } " +
|
||||
"}";
|
||||
Drawing d = json.getContext(null).readValue(str, Drawing.class);
|
||||
assertNotNull(d);
|
||||
assertNotNull(d.getMainShape());
|
||||
assertNotNull(d.getShapeOrNull());
|
||||
assertNotNull(d.getNullableShape());
|
||||
assertTrue(d.getMainShape().getActualInstance() instanceof EquilateralTriangle);
|
||||
assertTrue(d.getShapeOrNull().getActualInstance() instanceof IsoscelesTriangle);
|
||||
assertTrue(d.getNullableShape().getActualInstance() instanceof ScaleneTriangle);
|
||||
}
|
||||
|
||||
{
|
||||
String str = "{ " +
|
||||
" \"mainShape\": { \"shapeType\": \"Triangle\", \"triangleType\": \"EquilateralTriangle\" }, " +
|
||||
" \"shapeOrNull\": null, " +
|
||||
" \"nullableShape\": null " +
|
||||
"}";
|
||||
Drawing d = json.getContext(null).readValue(str, Drawing.class);
|
||||
assertNotNull(d);
|
||||
assertNotNull(d.getMainShape());
|
||||
assertNull(d.getShapeOrNull());
|
||||
assertNull(d.getNullableShape());
|
||||
assertTrue(d.getMainShape().getActualInstance() instanceof EquilateralTriangle);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a allOf schema can be deserialized into the expected class.
|
||||
*/
|
||||
@Test
|
||||
public void testAllOfSchema() throws Exception {
|
||||
{
|
||||
String str = "{ \"className\": \"Dog\", \"color\": \"white\", \"breed\": \"Siberian Husky\" }";
|
||||
|
||||
// We should be able to deserialize a dog into a Dog.
|
||||
Dog d = json.getContext(null).readValue(str, Dog.class);
|
||||
assertNotNull(d);
|
||||
assertEquals("white", d.getColor());
|
||||
}
|
||||
{
|
||||
String str = "{ \"pet_type\": \"ChildCat\", \"name\": \"fluffy\" }";
|
||||
GrandparentAnimal o = json.getContext(null).readValue(str, GrandparentAnimal.class);
|
||||
assertNotNull(o);
|
||||
assertTrue(o instanceof ParentPet);
|
||||
assertTrue(o instanceof ChildCat);
|
||||
ChildCat c = (ChildCat)o;
|
||||
assertEquals("fluffy", c.getName());
|
||||
}
|
||||
{
|
||||
String str = "{ \"pet_type\": \"ChildCat\", \"name\": \"fluffy\" }";
|
||||
ParentPet o = json.getContext(null).readValue(str, ParentPet.class);
|
||||
assertNotNull(o);
|
||||
assertTrue(o instanceof ChildCat);
|
||||
ChildCat c = (ChildCat)o;
|
||||
assertEquals("fluffy", c.getName());
|
||||
}
|
||||
{
|
||||
// Wrong discriminator value in the payload.
|
||||
String str = "{ \"pet_type\": \"Garbage\", \"name\": \"fluffy\" }";
|
||||
Exception exception = assertThrows(JsonMappingException.class, () -> {
|
||||
json.getContext(null).readValue(str, GrandparentAnimal.class);
|
||||
});
|
||||
assertTrue(exception.getMessage().contains("Could not resolve type id 'Garbage'"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullValueDisallowed() throws Exception {
|
||||
{
|
||||
String str = "{ \"id\": 123, \"petId\": 345, \"quantity\": 100, \"status\": \"placed\" }";
|
||||
Order o = json.getContext(null).readValue(str, Order.class);
|
||||
assertEquals(100L, (long)o.getQuantity());
|
||||
assertEquals(Order.StatusEnum.PLACED, o.getStatus());
|
||||
}
|
||||
{
|
||||
String str = "{ \"id\": 123, \"petId\": 345, \"quantity\": null }";
|
||||
Order o = json.getContext(null).readValue(str, Order.class);
|
||||
// TODO: the null value is not allowed per OAS document.
|
||||
// The deserialization should fail.
|
||||
assertNull(o.getQuantity());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a anyOf schema can be deserialized into the expected class.
|
||||
* The anyOf schema has a discriminator.
|
||||
*/
|
||||
@Test
|
||||
public void testAnyOfSchemaWithoutDiscriminator() throws Exception {
|
||||
{
|
||||
// TODO: the GmFruit defines a 'color' property, which should be allowed
|
||||
// in the input data, but the generated code does not have it.
|
||||
String str = "{ \"cultivar\": \"golden delicious\", \"origin\": \"California\" }";
|
||||
GmFruit o = json.getContext(null).readValue(str, GmFruit.class);
|
||||
assertTrue(o.getActualInstance() instanceof Apple);
|
||||
Apple inst = (Apple) o.getActualInstance();
|
||||
assertEquals("golden delicious", inst.getCultivar());
|
||||
assertEquals("California", inst.getOrigin());
|
||||
// TODO: the 'Color' property is not generated for the 'GmFruit'.
|
||||
//assertEquals("yellow", o.getColor());
|
||||
}
|
||||
{
|
||||
String str = "{ \"lengthCm\": 17 }";
|
||||
GmFruit o = json.getContext(null).readValue(str, GmFruit.class);
|
||||
assertTrue(o.getActualInstance() instanceof Banana);
|
||||
Banana inst = (Banana) o.getActualInstance();
|
||||
assertEquals(new java.math.BigDecimal(17), inst.getLengthCm());
|
||||
}
|
||||
{
|
||||
// Deserialize empty object. This should work because it will match either apple or banana.
|
||||
String str = "{ }";
|
||||
GmFruit o = json.getContext(null).readValue(str, GmFruit.class);
|
||||
// The payload matches against either apple or banana, so either model could be returned,
|
||||
// but the implementation always picks the first anyOf child schema that matches the
|
||||
// input payload.
|
||||
assertTrue(o.getActualInstance() instanceof Apple);
|
||||
}
|
||||
{
|
||||
// Deserialize the null value. This is not allowed because the 'gmFruit' schema
|
||||
// is not nullable.
|
||||
String str = "null";
|
||||
Exception exception = assertThrows(JsonMappingException.class, () -> {
|
||||
GmFruit o = json.getContext(null).readValue(str, GmFruit.class);
|
||||
});
|
||||
assertEquals("GmFruit cannot be null", exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,15 @@ package org.openapitools.client.api;
|
||||
import org.openapitools.client.*;
|
||||
import org.openapitools.client.auth.*;
|
||||
import java.io.File;
|
||||
import org.openapitools.client.model.ModelApiResponse;
|
||||
import org.openapitools.client.model.Pet;
|
||||
import org.openapitools.client.model.*;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -33,6 +34,7 @@ import java.util.Map;
|
||||
public class PetApiTest {
|
||||
|
||||
private final PetApi api = new PetApi();
|
||||
private final long petId = 5638l;
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
@@ -44,9 +46,61 @@ public class PetApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void addPetTest() throws ApiException {
|
||||
//Pet pet = null;
|
||||
//api.addPet(pet);
|
||||
// TODO: test validations
|
||||
// add pet
|
||||
Pet body = new Pet();
|
||||
body.setId(petId);
|
||||
body.setName("jersey2 java8 pet");
|
||||
Category category = new Category();
|
||||
category.setId(petId);
|
||||
category.setName("jersey2 java8 category");
|
||||
body.setCategory(category);
|
||||
body.setStatus(Pet.StatusEnum.AVAILABLE);
|
||||
body.setPhotoUrls(Arrays.asList("A", "B", "C"));
|
||||
Tag tag = new Tag();
|
||||
tag.setId(petId);
|
||||
tag.setName("jersey2 java8 tag");
|
||||
body.setTags(Arrays.asList(tag));
|
||||
|
||||
api.addPet(body);
|
||||
|
||||
//get pet by ID
|
||||
Pet result = api.getPetById(petId);
|
||||
Assert.assertEquals(result.getId(), body.getId());
|
||||
Assert.assertEquals(result.getCategory(), category);
|
||||
Assert.assertEquals(result.getName(), body.getName());
|
||||
Assert.assertEquals(result.getPhotoUrls(), body.getPhotoUrls());
|
||||
Assert.assertEquals(result.getStatus(), body.getStatus());
|
||||
Assert.assertEquals(result.getTags(), body.getTags());
|
||||
|
||||
// update pet
|
||||
api.updatePetWithForm(petId, "jersey2 java8 pet 2", "sold");
|
||||
|
||||
//get pet by ID
|
||||
Pet result2 = api.getPetById(petId);
|
||||
Assert.assertEquals(result2.getId(), body.getId());
|
||||
Assert.assertEquals(result2.getCategory(), category);
|
||||
Assert.assertEquals(result2.getName(), "jersey2 java8 pet 2");
|
||||
Assert.assertEquals(result2.getPhotoUrls(), body.getPhotoUrls());
|
||||
Assert.assertEquals(result2.getStatus(), Pet.StatusEnum.SOLD);
|
||||
Assert.assertEquals(result2.getTags(), body.getTags());
|
||||
|
||||
// delete pet
|
||||
api.deletePet(petId, "empty api key");
|
||||
|
||||
try {
|
||||
Pet result3 = api.getPetById(petId);
|
||||
Assert.assertEquals(false, true);
|
||||
} catch (ApiException e) {
|
||||
// System.err.println("Exception when calling PetApi#getPetById");
|
||||
// System.err.println("Status code: " + e.getCode());
|
||||
// System.err.println("Reason: " + e.getResponseBody());
|
||||
// System.err.println("Response headers: " + e.getResponseHeaders());
|
||||
|
||||
Assert.assertEquals(e.getCode(), 404);
|
||||
Assert.assertEquals(e.getResponseBody(), "{\"code\":1,\"type\":\"error\",\"message\":\"Pet not found\"}");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.openapitools.client.JSON;
|
||||
import org.openapitools.client.model.Pig;
|
||||
import org.openapitools.client.model.Whale;
|
||||
import org.openapitools.client.model.Zebra;
|
||||
@@ -39,8 +40,15 @@ public class MammalTest {
|
||||
* Model tests for Mammal
|
||||
*/
|
||||
@Test
|
||||
public void testMammal() {
|
||||
// TODO: test Mammal
|
||||
public void testMammal() throws Exception {
|
||||
Mammal m = new Mammal();
|
||||
Zebra z = new Zebra();
|
||||
z.setType(Zebra.TypeEnum.MOUNTAIN);
|
||||
z.setClassName("zebra");
|
||||
|
||||
m.setActualInstance(z);
|
||||
|
||||
Assert.assertEquals(JSON.getDefault().getMapper().writeValueAsString(m), "{\"type\":\"mountain\",\"className\":\"zebra\"}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
@@ -13,18 +13,15 @@
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.fasterxml.jackson.databind.type.MapType;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Zebra
|
||||
@@ -37,7 +34,29 @@ public class ZebraTest {
|
||||
*/
|
||||
@Test
|
||||
public void testZebra() {
|
||||
// TODO: test Zebra
|
||||
Zebra z = new Zebra();
|
||||
z.setClassName("zebra");
|
||||
Map<String, String> m = new HashMap<>();
|
||||
z.putAdditionalProperty("key1", "value1");
|
||||
z.putAdditionalProperty("key2", 12321);
|
||||
z.setType(Zebra.TypeEnum.MOUNTAIN);
|
||||
|
||||
JSON j = new JSON();
|
||||
try {
|
||||
// serialize
|
||||
Assert.assertEquals(j.getMapper().writeValueAsString(z), "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}");
|
||||
|
||||
// deserialize
|
||||
String zebraJson = "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}";
|
||||
Zebra zebraFromJson = j.getMapper().readValue(zebraJson, Zebra.class);
|
||||
Assert.assertEquals(zebraFromJson.getType(), Zebra.TypeEnum.MOUNTAIN);
|
||||
Assert.assertEquals(zebraFromJson.getClassName(), "zebra");
|
||||
Assert.assertEquals(zebraFromJson.getAdditionalProperties().size(), 2);
|
||||
Assert.assertEquals(zebraFromJson.getAdditionalProperty("key1"), "value1");
|
||||
Assert.assertEquals(zebraFromJson.getAdditionalProperty("key2"), 12321);
|
||||
} catch (Exception ex) {
|
||||
Assert.assertEquals(true, false); // exception shouldn't be thrown
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +64,23 @@ public class ZebraTest {
|
||||
*/
|
||||
@Test
|
||||
public void typeTest() {
|
||||
// TODO: test type
|
||||
String zebraJson = "{\"type\":\"mountain\",\"className\":\"zebra\",\"key1\":\"value1\",\"key2\":12321}";
|
||||
|
||||
JSON j = new JSON();
|
||||
TypeFactory typeFactory = j.getMapper().getTypeFactory();
|
||||
MapType mapType = typeFactory.constructMapType(HashMap.class, String.class, Object.class);
|
||||
try {
|
||||
HashMap<String, Object> map = j.getMapper().readValue(zebraJson, mapType);
|
||||
Assert.assertEquals(map.get("type"), "mountain");
|
||||
|
||||
Map<String,Object> result =
|
||||
j.getMapper().readValue(zebraJson, new TypeReference<Map<String,Object>>() {});
|
||||
|
||||
Assert.assertEquals(result.get("type"), "mountain");
|
||||
} catch (Exception ex) {
|
||||
Assert.assertEquals(true, false); // exception shouldn't be thrown
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +88,7 @@ public class ZebraTest {
|
||||
*/
|
||||
@Test
|
||||
public void classNameTest() {
|
||||
// TODO: test className
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user