mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 11:32:44 +00:00
[java][okhttp-gson] fix validateJsonObject (#13630)
* fix required check in java okhttp client * fix validateJsonObject in okhttp-gson, add test * move java-micronaut-client to test circleci
This commit is contained in:
@@ -206,9 +206,7 @@ public class Category {
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Category.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has required fields
|
||||
if (!Category.openapiRequiredFields.isEmpty()) { // has required fields but JSON object 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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,9 +236,7 @@ public class ModelApiResponse {
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (ModelApiResponse.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has required fields
|
||||
if (!ModelApiResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON object 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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,9 +376,7 @@ public class Order {
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Order.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has required fields
|
||||
if (!Order.openapiRequiredFields.isEmpty()) { // has required fields but JSON object 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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,9 +396,7 @@ public class Pet {
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Pet.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has required fields
|
||||
if (!Pet.openapiRequiredFields.isEmpty()) { // has required fields but JSON object 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()));
|
||||
}
|
||||
}
|
||||
@@ -413,7 +411,7 @@ public class Pet {
|
||||
if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) {
|
||||
Category.validateJsonObject(jsonObj.getAsJsonObject("category"));
|
||||
}
|
||||
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
|
||||
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()));
|
||||
}
|
||||
// ensure the json data is an array
|
||||
|
||||
@@ -206,9 +206,7 @@ public class Tag {
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (Tag.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has required fields
|
||||
if (!Tag.openapiRequiredFields.isEmpty()) { // has required fields but JSON object 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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,9 +386,7 @@ public class User {
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (User.openapiRequiredFields.isEmpty()) {
|
||||
return;
|
||||
} else { // has required fields
|
||||
if (!User.openapiRequiredFields.isEmpty()) { // has required fields but JSON object 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()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user