forked from loafle/openapi-generator-original
* [Java][Client] Fix #12556 Support primitives and arrays in oneOf * Regenerate petstore samples * Regenerate petstore test samples * Treat 'BigDecimal' as primtive datatype * Fix integration tests
This commit is contained in:
@@ -132,25 +132,26 @@ public class AdditionalPropertiesAnyType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesAnyType
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesAnyType
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesAnyType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesAnyType.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesAnyType.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class AdditionalPropertiesAnyType {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -133,25 +133,26 @@ public class AdditionalPropertiesArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesArray
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesArray
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesArray.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesArray.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesArray.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -177,9 +178,9 @@ public class AdditionalPropertiesArray {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesArray read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class AdditionalPropertiesBoolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesBoolean
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesBoolean
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesBoolean.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesBoolean.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesBoolean.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class AdditionalPropertiesBoolean {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesBoolean read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -480,25 +480,26 @@ public class AdditionalPropertiesClass {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesClass
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesClass
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesClass is not found in the empty JSON string", AdditionalPropertiesClass.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesClass.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@@ -521,9 +522,9 @@ public class AdditionalPropertiesClass {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesClass read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class AdditionalPropertiesInteger {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesInteger
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesInteger
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesInteger.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesInteger.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesInteger.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class AdditionalPropertiesInteger {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesInteger read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -133,25 +133,26 @@ public class AdditionalPropertiesNumber {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesNumber
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesNumber
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesNumber.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesNumber.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesNumber.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -177,9 +178,9 @@ public class AdditionalPropertiesNumber {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesNumber read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -133,25 +133,26 @@ public class AdditionalPropertiesObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesObject
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesObject
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesObject.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -177,9 +178,9 @@ public class AdditionalPropertiesObject {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesObject read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class AdditionalPropertiesString {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to AdditionalPropertiesString
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesString
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!AdditionalPropertiesString.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!AdditionalPropertiesString.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!AdditionalPropertiesString.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class AdditionalPropertiesString {
|
||||
|
||||
@Override
|
||||
public AdditionalPropertiesString read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -162,28 +162,28 @@ public class Animal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Animal
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Animal
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Animal.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Animal.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Animal is not found in the empty JSON string", Animal.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
String discriminatorValue = jsonObj.get("className").getAsString();
|
||||
String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString();
|
||||
switch (discriminatorValue) {
|
||||
case "BigCat":
|
||||
BigCat.validateJsonObject(jsonObj);
|
||||
BigCat.validateJsonElement(jsonElement);
|
||||
break;
|
||||
case "Cat":
|
||||
Cat.validateJsonObject(jsonObj);
|
||||
Cat.validateJsonElement(jsonElement);
|
||||
break;
|
||||
case "Dog":
|
||||
Dog.validateJsonObject(jsonObj);
|
||||
Dog.validateJsonElement(jsonElement);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
|
||||
|
||||
@@ -143,25 +143,26 @@ public class ArrayOfArrayOfNumberOnly {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ArrayOfArrayOfNumberOnly
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfArrayOfNumberOnly is not found in the empty JSON string", ArrayOfArrayOfNumberOnly.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ArrayOfArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("ArrayArrayNumber") != null && !jsonObj.get("ArrayArrayNumber").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `ArrayArrayNumber` to be an array in the JSON string but got `%s`", jsonObj.get("ArrayArrayNumber").toString()));
|
||||
@@ -188,9 +189,9 @@ public class ArrayOfArrayOfNumberOnly {
|
||||
|
||||
@Override
|
||||
public ArrayOfArrayOfNumberOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -143,25 +143,26 @@ public class ArrayOfNumberOnly {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ArrayOfNumberOnly
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ArrayOfNumberOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfNumberOnly is not found in the empty JSON string", ArrayOfNumberOnly.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("ArrayNumber") != null && !jsonObj.get("ArrayNumber").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `ArrayNumber` to be an array in the JSON string but got `%s`", jsonObj.get("ArrayNumber").toString()));
|
||||
@@ -188,9 +189,9 @@ public class ArrayOfNumberOnly {
|
||||
|
||||
@Override
|
||||
public ArrayOfNumberOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -215,25 +215,26 @@ public class ArrayTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ArrayTest
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ArrayTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ArrayTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ArrayTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayTest is not found in the empty JSON string", ArrayTest.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ArrayTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// ensure the optional json data is an array if present
|
||||
if (jsonObj.get("array_of_string") != null && !jsonObj.get("array_of_string").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_of_string` to be an array in the JSON string but got `%s`", jsonObj.get("array_of_string").toString()));
|
||||
@@ -268,9 +269,9 @@ public class ArrayTest {
|
||||
|
||||
@Override
|
||||
public ArrayTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -191,30 +191,30 @@ public class BigCat extends Cat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to BigCat
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to BigCat
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!BigCat.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!BigCat.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in BigCat is not found in the empty JSON string", BigCat.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!BigCat.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCat` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCat` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : BigCat.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,9 +239,9 @@ public class BigCat extends Cat {
|
||||
|
||||
@Override
|
||||
public BigCat read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -272,25 +272,26 @@ public class Capitalization {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Capitalization
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Capitalization
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Capitalization.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Capitalization.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Capitalization is not found in the empty JSON string", Capitalization.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Capitalization.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("smallCamel") != null && !jsonObj.get("smallCamel").isJsonNull()) && !jsonObj.get("smallCamel").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `smallCamel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("smallCamel").toString()));
|
||||
}
|
||||
@@ -331,9 +332,9 @@ public class Capitalization {
|
||||
|
||||
@Override
|
||||
public Capitalization read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -139,22 +139,22 @@ public class Cat extends Animal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Cat
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Cat
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Cat.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Cat.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Cat is not found in the empty JSON string", Cat.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
String discriminatorValue = jsonObj.get("className").getAsString();
|
||||
String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString();
|
||||
switch (discriminatorValue) {
|
||||
case "BigCat":
|
||||
BigCat.validateJsonObject(jsonObj);
|
||||
BigCat.validateJsonElement(jsonElement);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
|
||||
|
||||
@@ -161,32 +161,33 @@ public class Category {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Category
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Category
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Category.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Category.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Category is not found in the empty JSON string", Category.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Category.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Category.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if (!jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -212,9 +213,9 @@ public class Category {
|
||||
|
||||
@Override
|
||||
public Category read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class ClassModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ClassModel
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ClassModel
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ClassModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ClassModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ClassModel is not found in the empty JSON string", ClassModel.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ClassModel.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("_class") != null && !jsonObj.get("_class").isJsonNull()) && !jsonObj.get("_class").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `_class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("_class").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class ClassModel {
|
||||
|
||||
@Override
|
||||
public ClassModel read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class Client {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Client
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Client
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Client.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Client.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Client is not found in the empty JSON string", Client.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Client.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("client") != null && !jsonObj.get("client").isJsonNull()) && !jsonObj.get("client").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `client` to be a primitive type in the JSON string but got `%s`", jsonObj.get("client").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class Client {
|
||||
|
||||
@Override
|
||||
public Client read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -139,30 +139,30 @@ public class Dog extends Animal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Dog
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Dog
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Dog.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Dog.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Dog is not found in the empty JSON string", Dog.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Dog.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Dog.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,9 +187,9 @@ public class Dog extends Animal {
|
||||
|
||||
@Override
|
||||
public Dog read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -264,25 +264,26 @@ public class EnumArrays {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to EnumArrays
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to EnumArrays
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!EnumArrays.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!EnumArrays.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumArrays is not found in the empty JSON string", EnumArrays.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!EnumArrays.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("just_symbol") != null && !jsonObj.get("just_symbol").isJsonNull()) && !jsonObj.get("just_symbol").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `just_symbol` to be a primitive type in the JSON string but got `%s`", jsonObj.get("just_symbol").toString()));
|
||||
}
|
||||
@@ -312,9 +313,9 @@ public class EnumArrays {
|
||||
|
||||
@Override
|
||||
public EnumArrays read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -438,32 +438,33 @@ public class EnumTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to EnumTest
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to EnumTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!EnumTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!EnumTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumTest is not found in the empty JSON string", EnumTest.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!EnumTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : EnumTest.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("enum_string") != null && !jsonObj.get("enum_string").isJsonNull()) && !jsonObj.get("enum_string").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `enum_string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("enum_string").toString()));
|
||||
}
|
||||
@@ -492,9 +493,9 @@ public class EnumTest {
|
||||
|
||||
@Override
|
||||
public EnumTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -171,28 +171,29 @@ public class FileSchemaTestClass {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to FileSchemaTestClass
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to FileSchemaTestClass
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!FileSchemaTestClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!FileSchemaTestClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in FileSchemaTestClass is not found in the empty JSON string", FileSchemaTestClass.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!FileSchemaTestClass.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileSchemaTestClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileSchemaTestClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// validate the optional field `file`
|
||||
if (jsonObj.get("file") != null && !jsonObj.get("file").isJsonNull()) {
|
||||
ModelFile.validateJsonObject(jsonObj.getAsJsonObject("file"));
|
||||
ModelFile.validateJsonElement(jsonObj.get("file"));
|
||||
}
|
||||
if (jsonObj.get("files") != null && !jsonObj.get("files").isJsonNull()) {
|
||||
JsonArray jsonArrayfiles = jsonObj.getAsJsonArray("files");
|
||||
@@ -204,7 +205,7 @@ public class FileSchemaTestClass {
|
||||
|
||||
// validate the optional field `files` (array)
|
||||
for (int i = 0; i < jsonArrayfiles.size(); i++) {
|
||||
ModelFile.validateJsonObject(jsonArrayfiles.get(i).getAsJsonObject());
|
||||
ModelFile.validateJsonElement(jsonArrayfiles.get(i));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -230,9 +231,9 @@ public class FileSchemaTestClass {
|
||||
|
||||
@Override
|
||||
public FileSchemaTestClass read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -515,32 +515,33 @@ public class FormatTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to FormatTest
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to FormatTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!FormatTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!FormatTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in FormatTest is not found in the empty JSON string", FormatTest.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!FormatTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FormatTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FormatTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : FormatTest.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("string") != null && !jsonObj.get("string").isJsonNull()) && !jsonObj.get("string").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString()));
|
||||
}
|
||||
@@ -572,9 +573,9 @@ public class FormatTest {
|
||||
|
||||
@Override
|
||||
public FormatTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -152,25 +152,26 @@ public class HasOnlyReadOnly {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to HasOnlyReadOnly
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to HasOnlyReadOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!HasOnlyReadOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!HasOnlyReadOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in HasOnlyReadOnly is not found in the empty JSON string", HasOnlyReadOnly.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!HasOnlyReadOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HasOnlyReadOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HasOnlyReadOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("bar") != null && !jsonObj.get("bar").isJsonNull()) && !jsonObj.get("bar").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `bar` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bar").toString()));
|
||||
}
|
||||
@@ -199,9 +200,9 @@ public class HasOnlyReadOnly {
|
||||
|
||||
@Override
|
||||
public HasOnlyReadOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -297,25 +297,26 @@ public class MapTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to MapTest
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to MapTest
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!MapTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!MapTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in MapTest is not found in the empty JSON string", MapTest.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!MapTest.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MapTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MapTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@@ -338,9 +339,9 @@ public class MapTest {
|
||||
|
||||
@Override
|
||||
public MapTest read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -201,25 +201,26 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to MixedPropertiesAndAdditionalPropertiesClass
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to MixedPropertiesAndAdditionalPropertiesClass
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in MixedPropertiesAndAdditionalPropertiesClass is not found in the empty JSON string", MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!MixedPropertiesAndAdditionalPropertiesClass.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MixedPropertiesAndAdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MixedPropertiesAndAdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("uuid") != null && !jsonObj.get("uuid").isJsonNull()) && !jsonObj.get("uuid").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid").toString()));
|
||||
}
|
||||
@@ -245,9 +246,9 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
|
||||
|
||||
@Override
|
||||
public MixedPropertiesAndAdditionalPropertiesClass read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -160,25 +160,26 @@ public class Model200Response {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Model200Response
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Model200Response
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Model200Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Model200Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Model200Response is not found in the empty JSON string", Model200Response.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Model200Response.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Model200Response` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Model200Response` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("class") != null && !jsonObj.get("class").isJsonNull()) && !jsonObj.get("class").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("class").toString()));
|
||||
}
|
||||
@@ -204,9 +205,9 @@ public class Model200Response {
|
||||
|
||||
@Override
|
||||
public Model200Response read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -188,25 +188,26 @@ public class ModelApiResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ModelApiResponse
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ModelApiResponse
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ModelApiResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ModelApiResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelApiResponse is not found in the empty JSON string", ModelApiResponse.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ModelApiResponse.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelApiResponse` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelApiResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
|
||||
}
|
||||
@@ -235,9 +236,9 @@ public class ModelApiResponse {
|
||||
|
||||
@Override
|
||||
public ModelApiResponse read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class ModelFile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ModelFile
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ModelFile
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ModelFile.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ModelFile.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelFile is not found in the empty JSON string", ModelFile.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ModelFile.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelFile` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelFile` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("sourceURI") != null && !jsonObj.get("sourceURI").isJsonNull()) && !jsonObj.get("sourceURI").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `sourceURI` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sourceURI").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class ModelFile {
|
||||
|
||||
@Override
|
||||
public ModelFile read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class ModelList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ModelList
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ModelList
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ModelList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ModelList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelList is not found in the empty JSON string", ModelList.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ModelList.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelList` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelList` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("123-list") != null && !jsonObj.get("123-list").isJsonNull()) && !jsonObj.get("123-list").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `123-list` to be a primitive type in the JSON string but got `%s`", jsonObj.get("123-list").toString()));
|
||||
}
|
||||
@@ -176,9 +177,9 @@ public class ModelList {
|
||||
|
||||
@Override
|
||||
public ModelList read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class ModelReturn {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ModelReturn
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ModelReturn
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ModelReturn.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ModelReturn.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelReturn is not found in the empty JSON string", ModelReturn.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ModelReturn.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelReturn` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelReturn` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@@ -173,9 +174,9 @@ public class ModelReturn {
|
||||
|
||||
@Override
|
||||
public ModelReturn read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -209,32 +209,33 @@ public class Name {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Name
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Name
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Name.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Name.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Name is not found in the empty JSON string", Name.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Name.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Name` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Name` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Name.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("property") != null && !jsonObj.get("property").isJsonNull()) && !jsonObj.get("property").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `property` to be a primitive type in the JSON string but got `%s`", jsonObj.get("property").toString()));
|
||||
}
|
||||
@@ -260,9 +261,9 @@ public class Name {
|
||||
|
||||
@Override
|
||||
public Name read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -133,25 +133,26 @@ public class NumberOnly {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to NumberOnly
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to NumberOnly
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!NumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!NumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in NumberOnly is not found in the empty JSON string", NumberOnly.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!NumberOnly.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@@ -174,9 +175,9 @@ public class NumberOnly {
|
||||
|
||||
@Override
|
||||
public NumberOnly read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -322,25 +322,26 @@ public class Order {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Order
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Order
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Order.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Order.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Order is not found in the empty JSON string", Order.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Order.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Order` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Order` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
|
||||
}
|
||||
@@ -366,9 +367,9 @@ public class Order {
|
||||
|
||||
@Override
|
||||
public Order read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -189,25 +189,26 @@ public class OuterComposite {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to OuterComposite
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to OuterComposite
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!OuterComposite.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!OuterComposite.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in OuterComposite is not found in the empty JSON string", OuterComposite.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!OuterComposite.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OuterComposite` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OuterComposite` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("my_string") != null && !jsonObj.get("my_string").isJsonNull()) && !jsonObj.get("my_string").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `my_string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("my_string").toString()));
|
||||
}
|
||||
@@ -233,9 +234,9 @@ public class OuterComposite {
|
||||
|
||||
@Override
|
||||
public OuterComposite read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -345,35 +345,36 @@ public class Pet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Pet
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Pet
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Pet.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Pet.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Pet is not found in the empty JSON string", Pet.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Pet.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : Pet.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// validate the optional field `category`
|
||||
if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) {
|
||||
Category.validateJsonObject(jsonObj.getAsJsonObject("category"));
|
||||
Category.validateJsonElement(jsonObj.get("category"));
|
||||
}
|
||||
if (!jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
@@ -394,7 +395,7 @@ public class Pet {
|
||||
|
||||
// validate the optional field `tags` (array)
|
||||
for (int i = 0; i < jsonArraytags.size(); i++) {
|
||||
Tag.validateJsonObject(jsonArraytags.get(i).getAsJsonObject());
|
||||
Tag.validateJsonElement(jsonArraytags.get(i));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -423,9 +424,9 @@ public class Pet {
|
||||
|
||||
@Override
|
||||
public Pet read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -159,25 +159,26 @@ public class ReadOnlyFirst {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to ReadOnlyFirst
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to ReadOnlyFirst
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!ReadOnlyFirst.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!ReadOnlyFirst.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in ReadOnlyFirst is not found in the empty JSON string", ReadOnlyFirst.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!ReadOnlyFirst.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ReadOnlyFirst` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ReadOnlyFirst` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("bar") != null && !jsonObj.get("bar").isJsonNull()) && !jsonObj.get("bar").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `bar` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bar").toString()));
|
||||
}
|
||||
@@ -206,9 +207,9 @@ public class ReadOnlyFirst {
|
||||
|
||||
@Override
|
||||
public ReadOnlyFirst read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -132,25 +132,26 @@ public class SpecialModelName {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to SpecialModelName
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to SpecialModelName
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!SpecialModelName.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!SpecialModelName.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in SpecialModelName is not found in the empty JSON string", SpecialModelName.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!SpecialModelName.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialModelName` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialModelName` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
}
|
||||
|
||||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
||||
@@ -173,9 +174,9 @@ public class SpecialModelName {
|
||||
|
||||
@Override
|
||||
public SpecialModelName read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -160,25 +160,26 @@ public class Tag {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to Tag
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to Tag
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!Tag.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!Tag.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Tag is not found in the empty JSON string", Tag.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Tag.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
|
||||
}
|
||||
@@ -204,9 +205,9 @@ public class Tag {
|
||||
|
||||
@Override
|
||||
public Tag read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -260,32 +260,33 @@ public class TypeHolderDefault {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to TypeHolderDefault
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to TypeHolderDefault
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!TypeHolderDefault.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!TypeHolderDefault.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in TypeHolderDefault is not found in the empty JSON string", TypeHolderDefault.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!TypeHolderDefault.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderDefault` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderDefault` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : TypeHolderDefault.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if (!jsonObj.get("string_item").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `string_item` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_item").toString()));
|
||||
}
|
||||
@@ -317,9 +318,9 @@ public class TypeHolderDefault {
|
||||
|
||||
@Override
|
||||
public TypeHolderDefault read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -289,32 +289,33 @@ public class TypeHolderExample {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to TypeHolderExample
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to TypeHolderExample
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!TypeHolderExample.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!TypeHolderExample.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in TypeHolderExample is not found in the empty JSON string", TypeHolderExample.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!TypeHolderExample.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderExample` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderExample` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : TypeHolderExample.openapiRequiredFields) {
|
||||
if (jsonObj.get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
|
||||
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
|
||||
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if (!jsonObj.get("string_item").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `string_item` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_item").toString()));
|
||||
}
|
||||
@@ -346,9 +347,9 @@ public class TypeHolderExample {
|
||||
|
||||
@Override
|
||||
public TypeHolderExample read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -328,25 +328,26 @@ public class User {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to User
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to User
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!User.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!User.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in User is not found in the empty JSON string", User.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!User.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `User` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `User` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString()));
|
||||
}
|
||||
@@ -387,9 +388,9 @@ public class User {
|
||||
|
||||
@Override
|
||||
public User read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -991,25 +991,26 @@ public class XmlItem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the JSON Object and throws an exception if issues found
|
||||
* Validates the JSON Element and throws an exception if issues found
|
||||
*
|
||||
* @param jsonObj JSON Object
|
||||
* @throws IOException if the JSON Object is invalid with respect to XmlItem
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to XmlItem
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!XmlItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!XmlItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in XmlItem is not found in the empty JSON string", XmlItem.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet();
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!XmlItem.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `XmlItem` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `XmlItem` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("attribute_string") != null && !jsonObj.get("attribute_string").isJsonNull()) && !jsonObj.get("attribute_string").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `attribute_string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attribute_string").toString()));
|
||||
}
|
||||
@@ -1083,9 +1084,9 @@ public class XmlItem {
|
||||
|
||||
@Override
|
||||
public XmlItem read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
return thisAdapter.fromJsonTree(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
Reference in New Issue
Block a user