[java] fixed pojo template for nullable fields (#12630)

* [java] fixed pojo template for nullable fields

* regenerated samples
This commit is contained in:
Mauro Valota
2022-07-23 05:19:48 +02:00
committed by GitHub
parent 9f2f36c4fb
commit ea7a319a65
131 changed files with 260 additions and 260 deletions

View File

@@ -212,7 +212,7 @@ public class Category {
throw new IllegalArgumentException(String.format("The required field(s) %s in Category is not found in the empty JSON string", Category.openapiRequiredFields.toString()));
}
}
if (jsonObj.get("name") != null && !jsonObj.get("name").isJsonPrimitive()) {
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()));
}
}

View File

@@ -242,10 +242,10 @@ public class ModelApiResponse {
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelApiResponse is not found in the empty JSON string", ModelApiResponse.openapiRequiredFields.toString()));
}
}
if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonPrimitive()) {
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()));
}
if (jsonObj.get("message") != null && !jsonObj.get("message").isJsonPrimitive()) {
if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString()));
}
}

View File

@@ -382,7 +382,7 @@ public class Order {
throw new IllegalArgumentException(String.format("The required field(s) %s in Order is not found in the empty JSON string", Order.openapiRequiredFields.toString()));
}
}
if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonPrimitive()) {
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()));
}
}

View File

@@ -410,14 +410,14 @@ public class Pet {
}
}
// validate the optional field `category`
if (jsonObj.getAsJsonObject("category") != null) {
if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) {
Category.validateJsonObject(jsonObj.getAsJsonObject("category"));
}
if (jsonObj.get("name") != null && !jsonObj.get("name").isJsonPrimitive()) {
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()));
}
// ensure the json data is an array
if (jsonObj.get("photoUrls") != null && !jsonObj.get("photoUrls").isJsonArray()) {
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");
@@ -432,7 +432,7 @@ public class Pet {
Tag.validateJsonObject(jsonArraytags.get(i).getAsJsonObject());
};
}
if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonPrimitive()) {
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()));
}
}

View File

@@ -212,7 +212,7 @@ public class Tag {
throw new IllegalArgumentException(String.format("The required field(s) %s in Tag is not found in the empty JSON string", Tag.openapiRequiredFields.toString()));
}
}
if (jsonObj.get("name") != null && !jsonObj.get("name").isJsonPrimitive()) {
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()));
}
}

View File

@@ -392,22 +392,22 @@ public class User {
throw new IllegalArgumentException(String.format("The required field(s) %s in User is not found in the empty JSON string", User.openapiRequiredFields.toString()));
}
}
if (jsonObj.get("username") != null && !jsonObj.get("username").isJsonPrimitive()) {
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()));
}
if (jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonPrimitive()) {
if ((jsonObj.get("firstName") != null && !jsonObj.get("firstName").isJsonNull()) && !jsonObj.get("firstName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `firstName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("firstName").toString()));
}
if (jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonPrimitive()) {
if ((jsonObj.get("lastName") != null && !jsonObj.get("lastName").isJsonNull()) && !jsonObj.get("lastName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `lastName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastName").toString()));
}
if (jsonObj.get("email") != null && !jsonObj.get("email").isJsonPrimitive()) {
if ((jsonObj.get("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString()));
}
if (jsonObj.get("password") != null && !jsonObj.get("password").isJsonPrimitive()) {
if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString()));
}
if (jsonObj.get("phone") != null && !jsonObj.get("phone").isJsonPrimitive()) {
if ((jsonObj.get("phone") != null && !jsonObj.get("phone").isJsonNull()) && !jsonObj.get("phone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `phone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("phone").toString()));
}
}