mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 08:26:11 +00:00
[JAVA] fix ClassCastException validating an optional JsonArray which is a JsonNullable (#13448)
This commit is contained in:
committed by
GitHub
parent
517816d72b
commit
62d29c3be3
@@ -263,17 +263,19 @@ public class ArrayOfInlineAllOf {
|
||||
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()));
|
||||
}
|
||||
JsonArray jsonArrayarrayAllofDogProperty = jsonObj.getAsJsonArray("array_allof_dog_property");
|
||||
if (jsonArrayarrayAllofDogProperty != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("array_allof_dog_property").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_allof_dog_property` to be an array in the JSON string but got `%s`", jsonObj.get("array_allof_dog_property").toString()));
|
||||
}
|
||||
if (jsonObj.get("array_allof_dog_property") != null && !jsonObj.get("array_allof_dog_property").isJsonNull()) {
|
||||
JsonArray jsonArrayarrayAllofDogProperty = jsonObj.getAsJsonArray("array_allof_dog_property");
|
||||
if (jsonArrayarrayAllofDogProperty != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("array_allof_dog_property").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `array_allof_dog_property` to be an array in the JSON string but got `%s`", jsonObj.get("array_allof_dog_property").toString()));
|
||||
}
|
||||
|
||||
// validate the optional field `array_allof_dog_property` (array)
|
||||
for (int i = 0; i < jsonArrayarrayAllofDogProperty.size(); i++) {
|
||||
ArrayOfInlineAllOfArrayAllofDogPropertyInner.validateJsonObject(jsonArrayarrayAllofDogProperty.get(i).getAsJsonObject());
|
||||
};
|
||||
// validate the optional field `array_allof_dog_property` (array)
|
||||
for (int i = 0; i < jsonArrayarrayAllofDogProperty.size(); i++) {
|
||||
ArrayOfInlineAllOfArrayAllofDogPropertyInner.validateJsonObject(jsonArrayarrayAllofDogProperty.get(i).getAsJsonObject());
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -280,17 +280,19 @@ public class Drawing {
|
||||
if (jsonObj.get("nullableShape") != null && !jsonObj.get("nullableShape").isJsonNull()) {
|
||||
NullableShape.validateJsonObject(jsonObj.getAsJsonObject("nullableShape"));
|
||||
}
|
||||
JsonArray jsonArrayshapes = jsonObj.getAsJsonArray("shapes");
|
||||
if (jsonArrayshapes != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("shapes").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `shapes` to be an array in the JSON string but got `%s`", jsonObj.get("shapes").toString()));
|
||||
}
|
||||
if (jsonObj.get("shapes") != null && !jsonObj.get("shapes").isJsonNull()) {
|
||||
JsonArray jsonArrayshapes = jsonObj.getAsJsonArray("shapes");
|
||||
if (jsonArrayshapes != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("shapes").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `shapes` to be an array in the JSON string but got `%s`", jsonObj.get("shapes").toString()));
|
||||
}
|
||||
|
||||
// validate the optional field `shapes` (array)
|
||||
for (int i = 0; i < jsonArrayshapes.size(); i++) {
|
||||
Shape.validateJsonObject(jsonArrayshapes.get(i).getAsJsonObject());
|
||||
};
|
||||
// validate the optional field `shapes` (array)
|
||||
for (int i = 0; i < jsonArrayshapes.size(); i++) {
|
||||
Shape.validateJsonObject(jsonArrayshapes.get(i).getAsJsonObject());
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -226,17 +226,19 @@ public class FileSchemaTestClass {
|
||||
if (jsonObj.get("file") != null && !jsonObj.get("file").isJsonNull()) {
|
||||
ModelFile.validateJsonObject(jsonObj.getAsJsonObject("file"));
|
||||
}
|
||||
JsonArray jsonArrayfiles = jsonObj.getAsJsonArray("files");
|
||||
if (jsonArrayfiles != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("files").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `files` to be an array in the JSON string but got `%s`", jsonObj.get("files").toString()));
|
||||
}
|
||||
if (jsonObj.get("files") != null && !jsonObj.get("files").isJsonNull()) {
|
||||
JsonArray jsonArrayfiles = jsonObj.getAsJsonArray("files");
|
||||
if (jsonArrayfiles != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("files").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `files` to be an array in the JSON string but got `%s`", jsonObj.get("files").toString()));
|
||||
}
|
||||
|
||||
// validate the optional field `files` (array)
|
||||
for (int i = 0; i < jsonArrayfiles.size(); i++) {
|
||||
ModelFile.validateJsonObject(jsonArrayfiles.get(i).getAsJsonObject());
|
||||
};
|
||||
// validate the optional field `files` (array)
|
||||
for (int i = 0; i < jsonArrayfiles.size(); i++) {
|
||||
ModelFile.validateJsonObject(jsonArrayfiles.get(i).getAsJsonObject());
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -417,17 +417,19 @@ public class Pet {
|
||||
if ((jsonObj.get("photoUrls") != null && !jsonObj.get("photoUrls").isJsonNull()) && !jsonObj.get("photoUrls").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `photoUrls` to be an array in the JSON string but got `%s`", jsonObj.get("photoUrls").toString()));
|
||||
}
|
||||
JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags");
|
||||
if (jsonArraytags != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("tags").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString()));
|
||||
}
|
||||
if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull()) {
|
||||
JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags");
|
||||
if (jsonArraytags != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("tags").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString()));
|
||||
}
|
||||
|
||||
// validate the optional field `tags` (array)
|
||||
for (int i = 0; i < jsonArraytags.size(); i++) {
|
||||
Tag.validateJsonObject(jsonArraytags.get(i).getAsJsonObject());
|
||||
};
|
||||
// validate the optional field `tags` (array)
|
||||
for (int i = 0; i < jsonArraytags.size(); i++) {
|
||||
Tag.validateJsonObject(jsonArraytags.get(i).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()));
|
||||
|
||||
@@ -415,17 +415,19 @@ public class PetWithRequiredTags {
|
||||
if ((jsonObj.get("photoUrls") != null && !jsonObj.get("photoUrls").isJsonNull()) && !jsonObj.get("photoUrls").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `photoUrls` to be an array in the JSON string but got `%s`", jsonObj.get("photoUrls").toString()));
|
||||
}
|
||||
JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags");
|
||||
if (jsonArraytags != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("tags").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString()));
|
||||
}
|
||||
if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonNull()) {
|
||||
JsonArray jsonArraytags = jsonObj.getAsJsonArray("tags");
|
||||
if (jsonArraytags != null) {
|
||||
// ensure the json data is an array
|
||||
if (!jsonObj.get("tags").isJsonArray()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString()));
|
||||
}
|
||||
|
||||
// validate the optional field `tags` (array)
|
||||
for (int i = 0; i < jsonArraytags.size(); i++) {
|
||||
Tag.validateJsonObject(jsonArraytags.get(i).getAsJsonObject());
|
||||
};
|
||||
// validate the optional field `tags` (array)
|
||||
for (int i = 0; i < jsonArraytags.size(); i++) {
|
||||
Tag.validateJsonObject(jsonArraytags.get(i).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()));
|
||||
|
||||
Reference in New Issue
Block a user