mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 23:17:04 +00:00
[Java][jersey2] Fix generated client code for oneOf models if datatype includes arrays (#18042)
* Add java-jersey2 sample with mixed oneOf * [java][jersey2]Fix client generation if oneOf contains an array type Changes: * Change jersey2/oneof_model template to use composed schema data * Change adding of imports in AbstractJavaCodegen to use composed schema data * Add escapedDataType property to CodegenProperty so that the data type may be part of identifiers (e.g. in getters) * Update samples * Add sample for multiple array in oneOf * Fix generation of constructors with same erasures * Update samples again * Version bump * Add new sample folders to CI * Make primitive handling more explicit * Replace escapedDataType property with Mustache lambda * Update samples with new primitive handling and sanitization lambda
This commit is contained in:
@@ -29,6 +29,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import org.openapitools.client.model.Animal;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.openapitools.client.JSON;
|
||||
|
||||
@@ -92,19 +92,9 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
|
||||
int match = 0;
|
||||
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
|
||||
// deserialize Apple
|
||||
// deserialize Apple (nullable)
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Apple.class.equals(Integer.class) || Apple.class.equals(Long.class) || Apple.class.equals(Float.class) || Apple.class.equals(Double.class) || Apple.class.equals(Boolean.class) || Apple.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Apple.class.equals(Integer.class) || Apple.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Apple.class.equals(Float.class) || Apple.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Apple.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Apple.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Apple.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -121,16 +111,6 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
// deserialize Banana
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Banana.class.equals(Integer.class) || Banana.class.equals(Long.class) || Banana.class.equals(Float.class) || Banana.class.equals(Double.class) || Banana.class.equals(Boolean.class) || Banana.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Banana.class.equals(Integer.class) || Banana.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Banana.class.equals(Float.class) || Banana.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Banana.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Banana.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Banana.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -169,7 +149,7 @@ public class Fruit extends AbstractOpenApiSchema {
|
||||
}
|
||||
|
||||
public Fruit(Apple o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
super("oneOf", Boolean.TRUE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,17 +95,6 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
// deserialize AppleReq
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (AppleReq.class.equals(Integer.class) || AppleReq.class.equals(Long.class) || AppleReq.class.equals(Float.class) || AppleReq.class.equals(Double.class) || AppleReq.class.equals(Boolean.class) || AppleReq.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((AppleReq.class.equals(Integer.class) || AppleReq.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((AppleReq.class.equals(Float.class) || AppleReq.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (AppleReq.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (AppleReq.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
attemptParsing |= (token == JsonToken.VALUE_NULL);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(AppleReq.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -122,17 +111,6 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
// deserialize BananaReq
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (BananaReq.class.equals(Integer.class) || BananaReq.class.equals(Long.class) || BananaReq.class.equals(Float.class) || BananaReq.class.equals(Double.class) || BananaReq.class.equals(Boolean.class) || BananaReq.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((BananaReq.class.equals(Integer.class) || BananaReq.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((BananaReq.class.equals(Float.class) || BananaReq.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (BananaReq.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (BananaReq.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
attemptParsing |= (token == JsonToken.VALUE_NULL);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(BananaReq.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -171,12 +149,12 @@ public class FruitReq extends AbstractOpenApiSchema {
|
||||
}
|
||||
|
||||
public FruitReq(AppleReq o) {
|
||||
super("oneOf", Boolean.TRUE);
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
public FruitReq(BananaReq o) {
|
||||
super("oneOf", Boolean.TRUE);
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,45 +119,9 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
|
||||
int match = 0;
|
||||
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
|
||||
// deserialize Pig
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Pig.class.equals(Integer.class) || Pig.class.equals(Long.class) || Pig.class.equals(Float.class) || Pig.class.equals(Double.class) || Pig.class.equals(Boolean.class) || Pig.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Pig.class.equals(Integer.class) || Pig.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Pig.class.equals(Float.class) || Pig.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Pig.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Pig.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Pig'", e);
|
||||
}
|
||||
|
||||
// deserialize Whale
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Whale.class.equals(Integer.class) || Whale.class.equals(Long.class) || Whale.class.equals(Float.class) || Whale.class.equals(Double.class) || Whale.class.equals(Boolean.class) || Whale.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Whale.class.equals(Integer.class) || Whale.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Whale.class.equals(Float.class) || Whale.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Whale.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Whale.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Whale.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -174,16 +138,6 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
// deserialize Zebra
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Zebra.class.equals(Integer.class) || Zebra.class.equals(Long.class) || Zebra.class.equals(Float.class) || Zebra.class.equals(Double.class) || Zebra.class.equals(Boolean.class) || Zebra.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Zebra.class.equals(Integer.class) || Zebra.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Zebra.class.equals(Float.class) || Zebra.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Zebra.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Zebra.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Zebra.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -197,6 +151,22 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
log.log(Level.FINER, "Input data does not match schema 'Zebra'", e);
|
||||
}
|
||||
|
||||
// deserialize Pig
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Pig'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
Mammal ret = new Mammal();
|
||||
ret.setActualInstance(deserialized);
|
||||
@@ -270,11 +240,6 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
public int hashCode() {
|
||||
return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties);
|
||||
}
|
||||
public Mammal(Pig o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
public Mammal(Whale o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
@@ -285,6 +250,11 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
public Mammal(Pig o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
static {
|
||||
schemas.put("Pig", new GenericType<Pig>() {
|
||||
});
|
||||
@@ -317,11 +287,6 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (JSON.isInstanceOf(Pig.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Whale.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
@@ -332,6 +297,11 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Pig.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Invalid instance type. Must be Pig, Whale, Zebra");
|
||||
}
|
||||
|
||||
@@ -346,17 +316,6 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Pig`. If the actual instance is not `Pig`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Pig`
|
||||
* @throws ClassCastException if the instance is not `Pig`
|
||||
*/
|
||||
public Pig getPig() throws ClassCastException {
|
||||
return (Pig)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Whale`. If the actual instance is not `Whale`,
|
||||
* the ClassCastException will be thrown.
|
||||
@@ -379,5 +338,16 @@ public class Mammal extends AbstractOpenApiSchema {
|
||||
return (Zebra)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Pig`. If the actual instance is not `Pig`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Pig`
|
||||
* @throws ClassCastException if the instance is not `Pig`
|
||||
*/
|
||||
public Pig getPig() throws ClassCastException {
|
||||
return (Pig)super.getActualInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -114,47 +114,9 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
|
||||
int match = 0;
|
||||
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Quadrilateral.class.equals(Integer.class) || Quadrilateral.class.equals(Long.class) || Quadrilateral.class.equals(Float.class) || Quadrilateral.class.equals(Double.class) || Quadrilateral.class.equals(Boolean.class) || Quadrilateral.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Quadrilateral.class.equals(Integer.class) || Quadrilateral.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Quadrilateral.class.equals(Float.class) || Quadrilateral.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Quadrilateral.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Quadrilateral.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
attemptParsing |= (token == JsonToken.VALUE_NULL);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Quadrilateral'", e);
|
||||
}
|
||||
|
||||
// deserialize Triangle
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Triangle.class.equals(Integer.class) || Triangle.class.equals(Long.class) || Triangle.class.equals(Float.class) || Triangle.class.equals(Double.class) || Triangle.class.equals(Boolean.class) || Triangle.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Triangle.class.equals(Integer.class) || Triangle.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Triangle.class.equals(Float.class) || Triangle.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Triangle.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Triangle.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
attemptParsing |= (token == JsonToken.VALUE_NULL);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -168,6 +130,22 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
log.log(Level.FINER, "Input data does not match schema 'Triangle'", e);
|
||||
}
|
||||
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Quadrilateral'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
NullableShape ret = new NullableShape();
|
||||
ret.setActualInstance(deserialized);
|
||||
@@ -241,13 +219,13 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
public int hashCode() {
|
||||
return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties);
|
||||
}
|
||||
public NullableShape(Quadrilateral o) {
|
||||
super("oneOf", Boolean.TRUE);
|
||||
public NullableShape(Triangle o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
public NullableShape(Triangle o) {
|
||||
super("oneOf", Boolean.TRUE);
|
||||
public NullableShape(Quadrilateral o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
@@ -285,12 +263,12 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
@@ -309,17 +287,6 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Quadrilateral`
|
||||
* @throws ClassCastException if the instance is not `Quadrilateral`
|
||||
*/
|
||||
public Quadrilateral getQuadrilateral() throws ClassCastException {
|
||||
return (Quadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Triangle`. If the actual instance is not `Triangle`,
|
||||
* the ClassCastException will be thrown.
|
||||
@@ -331,5 +298,16 @@ public class NullableShape extends AbstractOpenApiSchema {
|
||||
return (Triangle)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Quadrilateral`
|
||||
* @throws ClassCastException if the instance is not `Quadrilateral`
|
||||
*/
|
||||
public Quadrilateral getQuadrilateral() throws ClassCastException {
|
||||
return (Quadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -117,16 +117,6 @@ public class Pig extends AbstractOpenApiSchema {
|
||||
// deserialize BasquePig
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (BasquePig.class.equals(Integer.class) || BasquePig.class.equals(Long.class) || BasquePig.class.equals(Float.class) || BasquePig.class.equals(Double.class) || BasquePig.class.equals(Boolean.class) || BasquePig.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((BasquePig.class.equals(Integer.class) || BasquePig.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((BasquePig.class.equals(Float.class) || BasquePig.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (BasquePig.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (BasquePig.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(BasquePig.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -143,16 +133,6 @@ public class Pig extends AbstractOpenApiSchema {
|
||||
// deserialize DanishPig
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (DanishPig.class.equals(Integer.class) || DanishPig.class.equals(Long.class) || DanishPig.class.equals(Float.class) || DanishPig.class.equals(Double.class) || DanishPig.class.equals(Boolean.class) || DanishPig.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((DanishPig.class.equals(Integer.class) || DanishPig.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((DanishPig.class.equals(Float.class) || DanishPig.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (DanishPig.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (DanishPig.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(DanishPig.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
|
||||
@@ -114,45 +114,9 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
|
||||
int match = 0;
|
||||
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
|
||||
// deserialize ComplexQuadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (ComplexQuadrilateral.class.equals(Integer.class) || ComplexQuadrilateral.class.equals(Long.class) || ComplexQuadrilateral.class.equals(Float.class) || ComplexQuadrilateral.class.equals(Double.class) || ComplexQuadrilateral.class.equals(Boolean.class) || ComplexQuadrilateral.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((ComplexQuadrilateral.class.equals(Integer.class) || ComplexQuadrilateral.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((ComplexQuadrilateral.class.equals(Float.class) || ComplexQuadrilateral.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (ComplexQuadrilateral.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (ComplexQuadrilateral.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'ComplexQuadrilateral'", e);
|
||||
}
|
||||
|
||||
// deserialize SimpleQuadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (SimpleQuadrilateral.class.equals(Integer.class) || SimpleQuadrilateral.class.equals(Long.class) || SimpleQuadrilateral.class.equals(Float.class) || SimpleQuadrilateral.class.equals(Double.class) || SimpleQuadrilateral.class.equals(Boolean.class) || SimpleQuadrilateral.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((SimpleQuadrilateral.class.equals(Integer.class) || SimpleQuadrilateral.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((SimpleQuadrilateral.class.equals(Float.class) || SimpleQuadrilateral.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (SimpleQuadrilateral.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (SimpleQuadrilateral.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(SimpleQuadrilateral.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -166,6 +130,22 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
log.log(Level.FINER, "Input data does not match schema 'SimpleQuadrilateral'", e);
|
||||
}
|
||||
|
||||
// deserialize ComplexQuadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'ComplexQuadrilateral'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
Quadrilateral ret = new Quadrilateral();
|
||||
ret.setActualInstance(deserialized);
|
||||
@@ -239,12 +219,12 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
public int hashCode() {
|
||||
return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties);
|
||||
}
|
||||
public Quadrilateral(ComplexQuadrilateral o) {
|
||||
public Quadrilateral(SimpleQuadrilateral o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
public Quadrilateral(SimpleQuadrilateral o) {
|
||||
public Quadrilateral(ComplexQuadrilateral o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
@@ -278,12 +258,12 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (JSON.isInstanceOf(ComplexQuadrilateral.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(SimpleQuadrilateral.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(SimpleQuadrilateral.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(ComplexQuadrilateral.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
@@ -302,17 +282,6 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `ComplexQuadrilateral`. If the actual instance is not `ComplexQuadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `ComplexQuadrilateral`
|
||||
* @throws ClassCastException if the instance is not `ComplexQuadrilateral`
|
||||
*/
|
||||
public ComplexQuadrilateral getComplexQuadrilateral() throws ClassCastException {
|
||||
return (ComplexQuadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `SimpleQuadrilateral`. If the actual instance is not `SimpleQuadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
@@ -324,5 +293,16 @@ public class Quadrilateral extends AbstractOpenApiSchema {
|
||||
return (SimpleQuadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `ComplexQuadrilateral`. If the actual instance is not `ComplexQuadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `ComplexQuadrilateral`
|
||||
* @throws ClassCastException if the instance is not `ComplexQuadrilateral`
|
||||
*/
|
||||
public ComplexQuadrilateral getComplexQuadrilateral() throws ClassCastException {
|
||||
return (ComplexQuadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -114,45 +114,9 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
|
||||
int match = 0;
|
||||
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Quadrilateral.class.equals(Integer.class) || Quadrilateral.class.equals(Long.class) || Quadrilateral.class.equals(Float.class) || Quadrilateral.class.equals(Double.class) || Quadrilateral.class.equals(Boolean.class) || Quadrilateral.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Quadrilateral.class.equals(Integer.class) || Quadrilateral.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Quadrilateral.class.equals(Float.class) || Quadrilateral.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Quadrilateral.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Quadrilateral.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Quadrilateral'", e);
|
||||
}
|
||||
|
||||
// deserialize Triangle
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Triangle.class.equals(Integer.class) || Triangle.class.equals(Long.class) || Triangle.class.equals(Float.class) || Triangle.class.equals(Double.class) || Triangle.class.equals(Boolean.class) || Triangle.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Triangle.class.equals(Integer.class) || Triangle.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Triangle.class.equals(Float.class) || Triangle.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Triangle.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Triangle.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -166,6 +130,22 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
log.log(Level.FINER, "Input data does not match schema 'Triangle'", e);
|
||||
}
|
||||
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Quadrilateral'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
Shape ret = new Shape();
|
||||
ret.setActualInstance(deserialized);
|
||||
@@ -239,12 +219,12 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
public int hashCode() {
|
||||
return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties);
|
||||
}
|
||||
public Shape(Quadrilateral o) {
|
||||
public Shape(Triangle o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
public Shape(Triangle o) {
|
||||
public Shape(Quadrilateral o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
@@ -278,12 +258,12 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
*/
|
||||
@Override
|
||||
public void setActualInstance(Object instance) {
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
@@ -302,17 +282,6 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Quadrilateral`
|
||||
* @throws ClassCastException if the instance is not `Quadrilateral`
|
||||
*/
|
||||
public Quadrilateral getQuadrilateral() throws ClassCastException {
|
||||
return (Quadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Triangle`. If the actual instance is not `Triangle`,
|
||||
* the ClassCastException will be thrown.
|
||||
@@ -324,5 +293,16 @@ public class Shape extends AbstractOpenApiSchema {
|
||||
return (Triangle)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Quadrilateral`
|
||||
* @throws ClassCastException if the instance is not `Quadrilateral`
|
||||
*/
|
||||
public Quadrilateral getQuadrilateral() throws ClassCastException {
|
||||
return (Quadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -114,47 +114,9 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
|
||||
int match = 0;
|
||||
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Quadrilateral.class.equals(Integer.class) || Quadrilateral.class.equals(Long.class) || Quadrilateral.class.equals(Float.class) || Quadrilateral.class.equals(Double.class) || Quadrilateral.class.equals(Boolean.class) || Quadrilateral.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Quadrilateral.class.equals(Integer.class) || Quadrilateral.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Quadrilateral.class.equals(Float.class) || Quadrilateral.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Quadrilateral.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Quadrilateral.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
attemptParsing |= (token == JsonToken.VALUE_NULL);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Quadrilateral'", e);
|
||||
}
|
||||
|
||||
// deserialize Triangle
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (Triangle.class.equals(Integer.class) || Triangle.class.equals(Long.class) || Triangle.class.equals(Float.class) || Triangle.class.equals(Double.class) || Triangle.class.equals(Boolean.class) || Triangle.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((Triangle.class.equals(Integer.class) || Triangle.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((Triangle.class.equals(Float.class) || Triangle.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (Triangle.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (Triangle.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
attemptParsing |= (token == JsonToken.VALUE_NULL);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(Triangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -168,6 +130,22 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
log.log(Level.FINER, "Input data does not match schema 'Triangle'", e);
|
||||
}
|
||||
|
||||
// deserialize Quadrilateral
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
if (attemptParsing) {
|
||||
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) {
|
||||
// deserialization failed, continue
|
||||
log.log(Level.FINER, "Input data does not match schema 'Quadrilateral'", e);
|
||||
}
|
||||
|
||||
if (match == 1) {
|
||||
ShapeOrNull ret = new ShapeOrNull();
|
||||
ret.setActualInstance(deserialized);
|
||||
@@ -241,13 +219,13 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
public int hashCode() {
|
||||
return Objects.hash(getActualInstance(), isNullable(), getSchemaType(), additionalProperties);
|
||||
}
|
||||
public ShapeOrNull(Quadrilateral o) {
|
||||
super("oneOf", Boolean.TRUE);
|
||||
public ShapeOrNull(Triangle o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
public ShapeOrNull(Triangle o) {
|
||||
super("oneOf", Boolean.TRUE);
|
||||
public ShapeOrNull(Quadrilateral o) {
|
||||
super("oneOf", Boolean.FALSE);
|
||||
setActualInstance(o);
|
||||
}
|
||||
|
||||
@@ -285,12 +263,12 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JSON.isInstanceOf(Triangle.class, instance, new HashSet<>())) {
|
||||
if (JSON.isInstanceOf(Quadrilateral.class, instance, new HashSet<>())) {
|
||||
super.setActualInstance(instance);
|
||||
return;
|
||||
}
|
||||
@@ -309,17 +287,6 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
return super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Quadrilateral`
|
||||
* @throws ClassCastException if the instance is not `Quadrilateral`
|
||||
*/
|
||||
public Quadrilateral getQuadrilateral() throws ClassCastException {
|
||||
return (Quadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Triangle`. If the actual instance is not `Triangle`,
|
||||
* the ClassCastException will be thrown.
|
||||
@@ -331,5 +298,16 @@ public class ShapeOrNull extends AbstractOpenApiSchema {
|
||||
return (Triangle)super.getActualInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual instance of `Quadrilateral`. If the actual instance is not `Quadrilateral`,
|
||||
* the ClassCastException will be thrown.
|
||||
*
|
||||
* @return The actual instance of `Quadrilateral`
|
||||
* @throws ClassCastException if the instance is not `Quadrilateral`
|
||||
*/
|
||||
public Quadrilateral getQuadrilateral() throws ClassCastException {
|
||||
return (Quadrilateral)super.getActualInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -122,16 +122,6 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
// deserialize EquilateralTriangle
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (EquilateralTriangle.class.equals(Integer.class) || EquilateralTriangle.class.equals(Long.class) || EquilateralTriangle.class.equals(Float.class) || EquilateralTriangle.class.equals(Double.class) || EquilateralTriangle.class.equals(Boolean.class) || EquilateralTriangle.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((EquilateralTriangle.class.equals(Integer.class) || EquilateralTriangle.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((EquilateralTriangle.class.equals(Float.class) || EquilateralTriangle.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (EquilateralTriangle.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (EquilateralTriangle.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(EquilateralTriangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -148,16 +138,6 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
// deserialize IsoscelesTriangle
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (IsoscelesTriangle.class.equals(Integer.class) || IsoscelesTriangle.class.equals(Long.class) || IsoscelesTriangle.class.equals(Float.class) || IsoscelesTriangle.class.equals(Double.class) || IsoscelesTriangle.class.equals(Boolean.class) || IsoscelesTriangle.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((IsoscelesTriangle.class.equals(Integer.class) || IsoscelesTriangle.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((IsoscelesTriangle.class.equals(Float.class) || IsoscelesTriangle.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (IsoscelesTriangle.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (IsoscelesTriangle.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(IsoscelesTriangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
@@ -174,16 +154,6 @@ public class Triangle extends AbstractOpenApiSchema {
|
||||
// deserialize ScaleneTriangle
|
||||
try {
|
||||
boolean attemptParsing = true;
|
||||
// ensure that we respect type coercion as set on the client ObjectMapper
|
||||
if (ScaleneTriangle.class.equals(Integer.class) || ScaleneTriangle.class.equals(Long.class) || ScaleneTriangle.class.equals(Float.class) || ScaleneTriangle.class.equals(Double.class) || ScaleneTriangle.class.equals(Boolean.class) || ScaleneTriangle.class.equals(String.class)) {
|
||||
attemptParsing = typeCoercion;
|
||||
if (!attemptParsing) {
|
||||
attemptParsing |= ((ScaleneTriangle.class.equals(Integer.class) || ScaleneTriangle.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
|
||||
attemptParsing |= ((ScaleneTriangle.class.equals(Float.class) || ScaleneTriangle.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
|
||||
attemptParsing |= (ScaleneTriangle.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
|
||||
attemptParsing |= (ScaleneTriangle.class.equals(String.class) && token == JsonToken.VALUE_STRING);
|
||||
}
|
||||
}
|
||||
if (attemptParsing) {
|
||||
deserialized = tree.traverse(jp.getCodec()).readValueAs(ScaleneTriangle.class);
|
||||
// TODO: there is no validation against JSON schema constraints
|
||||
|
||||
Reference in New Issue
Block a user