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:
@@ -206,17 +206,18 @@ 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()));
|
||||
}
|
||||
}
|
||||
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()));
|
||||
}
|
||||
@@ -259,8 +260,9 @@ public class Category {
|
||||
|
||||
@Override
|
||||
public Category read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
Category instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
@@ -234,17 +234,18 @@ 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()));
|
||||
}
|
||||
}
|
||||
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()));
|
||||
}
|
||||
@@ -290,8 +291,9 @@ public class ModelApiResponse {
|
||||
|
||||
@Override
|
||||
public ModelApiResponse read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
ModelApiResponse instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
@@ -368,17 +368,18 @@ 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()));
|
||||
}
|
||||
}
|
||||
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()));
|
||||
}
|
||||
@@ -421,8 +422,9 @@ public class Order {
|
||||
|
||||
@Override
|
||||
public Order read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
Order instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
@@ -394,27 +394,28 @@ 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()));
|
||||
}
|
||||
}
|
||||
|
||||
// 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()));
|
||||
@@ -435,7 +436,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));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -481,8 +482,9 @@ public class Pet {
|
||||
|
||||
@Override
|
||||
public Pet read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
Pet instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
@@ -406,27 +406,28 @@ public class PetWithRequiredNullableCases1 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 PetWithRequiredNullableCases1
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to PetWithRequiredNullableCases1
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!PetWithRequiredNullableCases1.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!PetWithRequiredNullableCases1.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in PetWithRequiredNullableCases1 is not found in the empty JSON string", PetWithRequiredNullableCases1.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : PetWithRequiredNullableCases1.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") != 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()));
|
||||
@@ -447,7 +448,7 @@ public class PetWithRequiredNullableCases1 {
|
||||
|
||||
// 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));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -493,8 +494,9 @@ public class PetWithRequiredNullableCases1 {
|
||||
|
||||
@Override
|
||||
public PetWithRequiredNullableCases1 read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
PetWithRequiredNullableCases1 instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
@@ -394,27 +394,28 @@ public class PetWithRequiredNullableCases2 {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 PetWithRequiredNullableCases2
|
||||
* @param jsonElement JSON Element
|
||||
* @throws IOException if the JSON Element is invalid with respect to PetWithRequiredNullableCases2
|
||||
*/
|
||||
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
|
||||
if (jsonObj == null) {
|
||||
if (!PetWithRequiredNullableCases2.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
|
||||
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
||||
if (jsonElement == null) {
|
||||
if (!PetWithRequiredNullableCases2.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in PetWithRequiredNullableCases2 is not found in the empty JSON string", PetWithRequiredNullableCases2.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// check to make sure all required properties/fields are present in the JSON string
|
||||
for (String requiredField : PetWithRequiredNullableCases2.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()));
|
||||
@@ -435,7 +436,7 @@ public class PetWithRequiredNullableCases2 {
|
||||
|
||||
// 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));
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -481,8 +482,9 @@ public class PetWithRequiredNullableCases2 {
|
||||
|
||||
@Override
|
||||
public PetWithRequiredNullableCases2 read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
PetWithRequiredNullableCases2 instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
@@ -206,17 +206,18 @@ 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()));
|
||||
}
|
||||
}
|
||||
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()));
|
||||
}
|
||||
@@ -259,8 +260,9 @@ public class Tag {
|
||||
|
||||
@Override
|
||||
public Tag read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
Tag instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
@@ -374,17 +374,18 @@ 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()));
|
||||
}
|
||||
}
|
||||
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()));
|
||||
}
|
||||
@@ -442,8 +443,9 @@ public class User {
|
||||
|
||||
@Override
|
||||
public User read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
|
||||
validateJsonObject(jsonObj);
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
User instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
|
||||
Reference in New Issue
Block a user