From 083ddc7f77403f280c13e963ca5af2174fed48c9 Mon Sep 17 00:00:00 2001 From: Charles Treatman Date: Wed, 18 Oct 2023 16:27:04 -0500 Subject: [PATCH] regenerate samples --- .../client/model/DefaultValue.java | 5 ++ .../org/openapitools/client/model/Pet.java | 9 +++ .../org/openapitools/client/model/Query.java | 5 ++ .../client/model/StringEnumRef.java | 6 ++ .../openapitools/client/model/SomeObj.java | 9 +++ .../org/openapitools/client/model/Order.java | 9 +++ .../org/openapitools/client/model/Pet.java | 9 +++ .../org/openapitools/client/model/Order.java | 9 +++ .../org/openapitools/client/model/Pet.java | 9 +++ .../org/openapitools/client/model/BigCat.java | 5 ++ .../openapitools/client/model/EnumArrays.java | 14 +++++ .../openapitools/client/model/EnumClass.java | 6 ++ .../openapitools/client/model/EnumTest.java | 38 ++++++++++++ .../openapitools/client/model/MapTest.java | 5 ++ .../org/openapitools/client/model/Order.java | 9 +++ .../openapitools/client/model/OuterEnum.java | 6 ++ .../org/openapitools/client/model/Pet.java | 9 +++ .../org/openapitools/client/model/Order.java | 9 +++ .../org/openapitools/client/model/Pet.java | 9 +++ .../org/openapitools/client/model/Order.java | 9 +++ .../org/openapitools/client/model/Pet.java | 9 +++ .../model/PetWithRequiredNullableCases1.java | 9 +++ .../model/PetWithRequiredNullableCases2.java | 9 +++ .../org/openapitools/client/model/BigCat.java | 5 ++ .../openapitools/client/model/EnumArrays.java | 14 +++++ .../openapitools/client/model/EnumClass.java | 6 ++ .../openapitools/client/model/EnumTest.java | 38 ++++++++++++ .../openapitools/client/model/MapTest.java | 5 ++ .../org/openapitools/client/model/Order.java | 9 +++ .../openapitools/client/model/OuterEnum.java | 6 ++ .../org/openapitools/client/model/Pet.java | 9 +++ .../org/openapitools/client/model/Order.java | 9 +++ .../org/openapitools/client/model/Pet.java | 9 +++ .../org/openapitools/client/model/Order.java | 9 +++ .../org/openapitools/client/model/Pet.java | 9 +++ .../openapitools/client/model/EnumArrays.java | 14 +++++ .../openapitools/client/model/EnumClass.java | 6 ++ .../client/model/EnumStringDiscriminator.java | 5 ++ .../openapitools/client/model/EnumTest.java | 59 +++++++++++++++++++ .../openapitools/client/model/MapTest.java | 5 ++ .../org/openapitools/client/model/NewPet.java | 9 +++ .../org/openapitools/client/model/Order.java | 9 +++ .../openapitools/client/model/OuterEnum.java | 6 ++ .../client/model/OuterEnumDefaultValue.java | 6 ++ .../client/model/OuterEnumInteger.java | 6 ++ .../model/OuterEnumIntegerDefaultValue.java | 6 ++ .../org/openapitools/client/model/Pet.java | 9 +++ .../client/model/PetWithRequiredTags.java | 9 +++ .../org/openapitools/client/model/Zebra.java | 9 +++ 49 files changed, 502 insertions(+) diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java index a9d92978920d..6a7563cd1ed4 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DefaultValue.java @@ -106,6 +106,11 @@ public ArrayStringEnumDefaultEnum read(final JsonReader jsonReader) throws IOExc return ArrayStringEnumDefaultEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ArrayStringEnumDefaultEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ARRAY_STRING_ENUM_DEFAULT = "array_string_enum_default"; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java index 44a73022face..d72837765013 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -399,6 +404,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java index 7daca5795f00..453a9fd37d41 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Query.java @@ -104,6 +104,11 @@ public OutcomesEnum read(final JsonReader jsonReader) throws IOException { return OutcomesEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + OutcomesEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_OUTCOMES = "outcomes"; diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/StringEnumRef.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/StringEnumRef.java index fbd954c9d6ee..c786ac6c8423 100644 --- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/StringEnumRef.java +++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/StringEnumRef.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public StringEnumRef read(final JsonReader jsonReader) throws IOException { return StringEnumRef.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StringEnumRef.fromValue(value); + } } diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java index 5ae1a3adf775..ebe0199f829f 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/model/SomeObj.java @@ -97,6 +97,11 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { return TypeEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + TypeEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_$_TYPE = "$_type"; @@ -314,6 +319,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `$_type` + if (jsonObj.get("$_type") != null && !jsonObj.get("$_type").isJsonNull()) { + TypeEnum.validateJsonElement(jsonObj.get("$_type")); + } 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())); } diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java index ae66537b4824..8ebfab4c22a4 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Order.java @@ -115,6 +115,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -382,6 +387,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java index 69cec0b898e2..691d44432202 100644 --- a/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-3.1/src/main/java/org/openapitools/client/model/Pet.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -442,6 +447,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java index ae66537b4824..8ebfab4c22a4 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Order.java @@ -115,6 +115,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -382,6 +387,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java index 69cec0b898e2..691d44432202 100644 --- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Pet.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -442,6 +447,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/BigCat.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/BigCat.java index bc85b824e386..b685d1b61605 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/BigCat.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/BigCat.java @@ -101,6 +101,11 @@ public KindEnum read(final JsonReader jsonReader) throws IOException { return KindEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_KIND = "kind"; diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumArrays.java index c84d4fad4efa..2bf075043ec9 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -98,6 +98,11 @@ public JustSymbolEnum read(final JsonReader jsonReader) throws IOException { return JustSymbolEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + JustSymbolEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_JUST_SYMBOL = "just_symbol"; @@ -149,6 +154,11 @@ public ArrayEnumEnum read(final JsonReader jsonReader) throws IOException { return ArrayEnumEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ArrayEnumEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ARRAY_ENUM = "array_enum"; @@ -286,6 +296,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `just_symbol` + if (jsonObj.get("just_symbol") != null && !jsonObj.get("just_symbol").isJsonNull()) { + JustSymbolEnum.validateJsonElement(jsonObj.get("just_symbol")); + } // ensure the optional json data is an array if present if (jsonObj.get("array_enum") != null && !jsonObj.get("array_enum").isJsonNull() && !jsonObj.get("array_enum").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `array_enum` to be an array in the JSON string but got `%s`", jsonObj.get("array_enum").toString())); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumClass.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumClass.java index d3639fe679bb..c2dfd3aecd7c 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumClass.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumClass.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public EnumClass read(final JsonReader jsonReader) throws IOException { return EnumClass.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumClass.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumTest.java index eb4dac3d80a1..d0dac18f44d3 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/EnumTest.java @@ -99,6 +99,11 @@ public EnumStringEnum read(final JsonReader jsonReader) throws IOException { return EnumStringEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumStringEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_STRING = "enum_string"; @@ -152,6 +157,11 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti return EnumStringRequiredEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumStringRequiredEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_STRING_REQUIRED = "enum_string_required"; @@ -203,6 +213,11 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { return EnumIntegerEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Integer value = jsonElement.getAsInt(); + EnumIntegerEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_INTEGER = "enum_integer"; @@ -254,6 +269,11 @@ public EnumNumberEnum read(final JsonReader jsonReader) throws IOException { return EnumNumberEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Double value = jsonElement.getAsDouble(); + EnumNumberEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_NUMBER = "enum_number"; @@ -467,9 +487,27 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `enum_string` + if (jsonObj.get("enum_string") != null && !jsonObj.get("enum_string").isJsonNull()) { + EnumStringEnum.validateJsonElement(jsonObj.get("enum_string")); + } if (!jsonObj.get("enum_string_required").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `enum_string_required` to be a primitive type in the JSON string but got `%s`", jsonObj.get("enum_string_required").toString())); } + // validate the required field `enum_string_required` + EnumStringRequiredEnum.validateJsonElement(jsonObj.get("enum_string_required")); + // validate the optional field `enum_integer` + if (jsonObj.get("enum_integer") != null && !jsonObj.get("enum_integer").isJsonNull()) { + EnumIntegerEnum.validateJsonElement(jsonObj.get("enum_integer")); + } + // validate the optional field `enum_number` + if (jsonObj.get("enum_number") != null && !jsonObj.get("enum_number").isJsonNull()) { + EnumNumberEnum.validateJsonElement(jsonObj.get("enum_number")); + } + // validate the optional field `outerEnum` + if (jsonObj.get("outerEnum") != null && !jsonObj.get("outerEnum").isJsonNull()) { + OuterEnum.validateJsonElement(jsonObj.get("outerEnum")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MapTest.java index 6afb183e497d..4111615eddc9 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MapTest.java @@ -102,6 +102,11 @@ public InnerEnum read(final JsonReader jsonReader) throws IOException { return InnerEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + InnerEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_MAP_OF_ENUM_STRING = "map_of_enum_string"; diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Order.java index 1d9a094e176c..7835c9aa54d0 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Order.java @@ -115,6 +115,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -344,6 +349,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterEnum.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterEnum.java index 40c7905b50b7..7f2bd742d75e 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterEnum.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterEnum.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public OuterEnum read(final JsonReader jsonReader) throws IOException { return OuterEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + OuterEnum.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Pet.java index 46fd792c466d..b52d215946d9 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Pet.java @@ -124,6 +124,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -401,6 +406,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java index ae66537b4824..8ebfab4c22a4 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Order.java @@ -115,6 +115,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -382,6 +387,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java index 69cec0b898e2..691d44432202 100644 --- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Pet.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -442,6 +447,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Order.java index ae66537b4824..8ebfab4c22a4 100644 --- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Order.java @@ -115,6 +115,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -382,6 +387,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Pet.java index 69cec0b898e2..691d44432202 100644 --- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Pet.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -442,6 +447,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases1.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases1.java index 1a60aace70bc..d02d925e4ef9 100644 --- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases1.java +++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases1.java @@ -123,6 +123,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -454,6 +459,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases2.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases2.java index 7e1fa54da98b..d8bbe12404ff 100644 --- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases2.java +++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/PetWithRequiredNullableCases2.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -442,6 +447,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/BigCat.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/BigCat.java index 98eba0fbbcff..18f2ee6d6bd0 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/BigCat.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/BigCat.java @@ -103,6 +103,11 @@ public KindEnum read(final JsonReader jsonReader) throws IOException { return KindEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + KindEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_KIND = "kind"; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumArrays.java index 655ff2065088..cfd7a4171fc3 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -100,6 +100,11 @@ public JustSymbolEnum read(final JsonReader jsonReader) throws IOException { return JustSymbolEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + JustSymbolEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_JUST_SYMBOL = "just_symbol"; @@ -151,6 +156,11 @@ public ArrayEnumEnum read(final JsonReader jsonReader) throws IOException { return ArrayEnumEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ArrayEnumEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ARRAY_ENUM = "array_enum"; @@ -311,6 +321,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `just_symbol` + if (jsonObj.get("just_symbol") != null && !jsonObj.get("just_symbol").isJsonNull()) { + JustSymbolEnum.validateJsonElement(jsonObj.get("just_symbol")); + } // ensure the optional json data is an array if present if (jsonObj.get("array_enum") != null && !jsonObj.get("array_enum").isJsonNull() && !jsonObj.get("array_enum").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `array_enum` to be an array in the JSON string but got `%s`", jsonObj.get("array_enum").toString())); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumClass.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumClass.java index 643c5d1d864d..5668c62bebe2 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumClass.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumClass.java @@ -20,6 +20,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -72,5 +73,10 @@ public EnumClass read(final JsonReader jsonReader) throws IOException { return EnumClass.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumClass.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumTest.java index 0ec996e7338a..f590a466338b 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/EnumTest.java @@ -101,6 +101,11 @@ public EnumStringEnum read(final JsonReader jsonReader) throws IOException { return EnumStringEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumStringEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_STRING = "enum_string"; @@ -154,6 +159,11 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti return EnumStringRequiredEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumStringRequiredEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_STRING_REQUIRED = "enum_string_required"; @@ -205,6 +215,11 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { return EnumIntegerEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Integer value = jsonElement.getAsInt(); + EnumIntegerEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_INTEGER = "enum_integer"; @@ -256,6 +271,11 @@ public EnumNumberEnum read(final JsonReader jsonReader) throws IOException { return EnumNumberEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Double value = jsonElement.getAsDouble(); + EnumNumberEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_NUMBER = "enum_number"; @@ -498,9 +518,27 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `enum_string` + if (jsonObj.get("enum_string") != null && !jsonObj.get("enum_string").isJsonNull()) { + EnumStringEnum.validateJsonElement(jsonObj.get("enum_string")); + } if (!jsonObj.get("enum_string_required").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `enum_string_required` to be a primitive type in the JSON string but got `%s`", jsonObj.get("enum_string_required").toString())); } + // validate the required field `enum_string_required` + EnumStringRequiredEnum.validateJsonElement(jsonObj.get("enum_string_required")); + // validate the optional field `enum_integer` + if (jsonObj.get("enum_integer") != null && !jsonObj.get("enum_integer").isJsonNull()) { + EnumIntegerEnum.validateJsonElement(jsonObj.get("enum_integer")); + } + // validate the optional field `enum_number` + if (jsonObj.get("enum_number") != null && !jsonObj.get("enum_number").isJsonNull()) { + EnumNumberEnum.validateJsonElement(jsonObj.get("enum_number")); + } + // validate the optional field `outerEnum` + if (jsonObj.get("outerEnum") != null && !jsonObj.get("outerEnum").isJsonNull()) { + OuterEnum.validateJsonElement(jsonObj.get("outerEnum")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/MapTest.java index 6958a69ffb32..ecdac8b00a37 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/MapTest.java @@ -104,6 +104,11 @@ public InnerEnum read(final JsonReader jsonReader) throws IOException { return InnerEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + InnerEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_MAP_OF_ENUM_STRING = "map_of_enum_string"; diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Order.java index 212ccc32fda3..95952ffda41f 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Order.java @@ -117,6 +117,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -377,6 +382,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/OuterEnum.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/OuterEnum.java index 86e01b2d8296..f9002dca2ded 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/OuterEnum.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/OuterEnum.java @@ -20,6 +20,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -72,5 +73,10 @@ public OuterEnum read(final JsonReader jsonReader) throws IOException { return OuterEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + OuterEnum.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Pet.java index 38dab5c2193c..db0704f99bb4 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Pet.java @@ -126,6 +126,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -434,6 +439,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java index b5181f246c51..a21e41e316cf 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Order.java @@ -118,6 +118,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -391,6 +396,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java index 19a7873eabe2..b9a7248b1b67 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-swagger1/src/main/java/org/openapitools/client/model/Pet.java @@ -125,6 +125,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -451,6 +456,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Order.java index 267f7d1326e0..ccea576a1ca4 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Order.java @@ -117,6 +117,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -390,6 +395,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Pet.java index ddc50c761778..a4f2ff9b7933 100644 --- a/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson-swagger2/src/main/java/org/openapitools/client/model/Pet.java @@ -124,6 +124,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -450,6 +455,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumArrays.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumArrays.java index 78f4b0aff16e..3ba3e0c3e423 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumArrays.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumArrays.java @@ -98,6 +98,11 @@ public JustSymbolEnum read(final JsonReader jsonReader) throws IOException { return JustSymbolEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + JustSymbolEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_JUST_SYMBOL = "just_symbol"; @@ -149,6 +154,11 @@ public ArrayEnumEnum read(final JsonReader jsonReader) throws IOException { return ArrayEnumEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ArrayEnumEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ARRAY_ENUM = "array_enum"; @@ -324,6 +334,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `just_symbol` + if (jsonObj.get("just_symbol") != null && !jsonObj.get("just_symbol").isJsonNull()) { + JustSymbolEnum.validateJsonElement(jsonObj.get("just_symbol")); + } // ensure the optional json data is an array if present if (jsonObj.get("array_enum") != null && !jsonObj.get("array_enum").isJsonNull() && !jsonObj.get("array_enum").isJsonArray()) { throw new IllegalArgumentException(String.format("Expected the field `array_enum` to be an array in the JSON string but got `%s`", jsonObj.get("array_enum").toString())); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumClass.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumClass.java index d3639fe679bb..c2dfd3aecd7c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumClass.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumClass.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public EnumClass read(final JsonReader jsonReader) throws IOException { return EnumClass.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumClass.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumStringDiscriminator.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumStringDiscriminator.java index 4c1681e8c321..48d26fda964a 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumStringDiscriminator.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumStringDiscriminator.java @@ -96,6 +96,11 @@ public EnumStrTypeEnum read(final JsonReader jsonReader) throws IOException { return EnumStrTypeEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumStrTypeEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_STR_TYPE = "enum_str_type"; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumTest.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumTest.java index 9e8e63d6fc6b..f0d68e57232e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/EnumTest.java @@ -103,6 +103,11 @@ public EnumStringEnum read(final JsonReader jsonReader) throws IOException { return EnumStringEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumStringEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_STRING = "enum_string"; @@ -156,6 +161,11 @@ public EnumStringRequiredEnum read(final JsonReader jsonReader) throws IOExcepti return EnumStringRequiredEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EnumStringRequiredEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_STRING_REQUIRED = "enum_string_required"; @@ -207,6 +217,11 @@ public EnumIntegerEnum read(final JsonReader jsonReader) throws IOException { return EnumIntegerEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Integer value = jsonElement.getAsInt(); + EnumIntegerEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_INTEGER = "enum_integer"; @@ -258,6 +273,11 @@ public EnumIntegerOnlyEnum read(final JsonReader jsonReader) throws IOException return EnumIntegerOnlyEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Integer value = jsonElement.getAsInt(); + EnumIntegerOnlyEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_INTEGER_ONLY = "enum_integer_only"; @@ -309,6 +329,11 @@ public EnumNumberEnum read(final JsonReader jsonReader) throws IOException { return EnumNumberEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Double value = jsonElement.getAsDouble(); + EnumNumberEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_ENUM_NUMBER = "enum_number"; @@ -679,9 +704,43 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `enum_string` + if (jsonObj.get("enum_string") != null && !jsonObj.get("enum_string").isJsonNull()) { + EnumStringEnum.validateJsonElement(jsonObj.get("enum_string")); + } if (!jsonObj.get("enum_string_required").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `enum_string_required` to be a primitive type in the JSON string but got `%s`", jsonObj.get("enum_string_required").toString())); } + // validate the required field `enum_string_required` + EnumStringRequiredEnum.validateJsonElement(jsonObj.get("enum_string_required")); + // validate the optional field `enum_integer` + if (jsonObj.get("enum_integer") != null && !jsonObj.get("enum_integer").isJsonNull()) { + EnumIntegerEnum.validateJsonElement(jsonObj.get("enum_integer")); + } + // validate the optional field `enum_integer_only` + if (jsonObj.get("enum_integer_only") != null && !jsonObj.get("enum_integer_only").isJsonNull()) { + EnumIntegerOnlyEnum.validateJsonElement(jsonObj.get("enum_integer_only")); + } + // validate the optional field `enum_number` + if (jsonObj.get("enum_number") != null && !jsonObj.get("enum_number").isJsonNull()) { + EnumNumberEnum.validateJsonElement(jsonObj.get("enum_number")); + } + // validate the optional field `outerEnum` + if (jsonObj.get("outerEnum") != null && !jsonObj.get("outerEnum").isJsonNull()) { + OuterEnum.validateJsonElement(jsonObj.get("outerEnum")); + } + // validate the optional field `outerEnumInteger` + if (jsonObj.get("outerEnumInteger") != null && !jsonObj.get("outerEnumInteger").isJsonNull()) { + OuterEnumInteger.validateJsonElement(jsonObj.get("outerEnumInteger")); + } + // validate the optional field `outerEnumDefaultValue` + if (jsonObj.get("outerEnumDefaultValue") != null && !jsonObj.get("outerEnumDefaultValue").isJsonNull()) { + OuterEnumDefaultValue.validateJsonElement(jsonObj.get("outerEnumDefaultValue")); + } + // validate the optional field `outerEnumIntegerDefaultValue` + if (jsonObj.get("outerEnumIntegerDefaultValue") != null && !jsonObj.get("outerEnumIntegerDefaultValue").isJsonNull()) { + OuterEnumIntegerDefaultValue.validateJsonElement(jsonObj.get("outerEnumIntegerDefaultValue")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/MapTest.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/MapTest.java index 44f4e60d9330..b404a1f1b7c1 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/MapTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/MapTest.java @@ -102,6 +102,11 @@ public InnerEnum read(final JsonReader jsonReader) throws IOException { return InnerEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + InnerEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_MAP_OF_ENUM_STRING = "map_of_enum_string"; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NewPet.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NewPet.java index 78ad57f234a2..f5300eb6d167 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NewPet.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NewPet.java @@ -127,6 +127,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -470,6 +475,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java index f7763b303dac..443cd66cc9e8 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Order.java @@ -115,6 +115,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -382,6 +387,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnum.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnum.java index 00d9c2a1a5c7..97220a992dc8 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnum.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnum.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public OuterEnum read(final JsonReader jsonReader) throws IOException { return OuterEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + OuterEnum.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java index 6643886ce21d..09897c14f170 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumDefaultValue.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public OuterEnumDefaultValue read(final JsonReader jsonReader) throws IOExceptio return OuterEnumDefaultValue.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + OuterEnumDefaultValue.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumInteger.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumInteger.java index a30b2089e6f6..ae49256b3bad 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumInteger.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumInteger.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public OuterEnumInteger read(final JsonReader jsonReader) throws IOException { return OuterEnumInteger.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Integer value = jsonElement.getAsInt(); + OuterEnumInteger.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java index 3f6efe9ce977..8d5372492bed 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/OuterEnumIntegerDefaultValue.java @@ -18,6 +18,7 @@ import java.io.IOException; import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; @@ -70,5 +71,10 @@ public OuterEnumIntegerDefaultValue read(final JsonReader jsonReader) throws IOE return OuterEnumIntegerDefaultValue.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + Integer value = jsonElement.getAsInt(); + OuterEnumIntegerDefaultValue.fromValue(value); + } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java index b1505e2c864d..9abee8b2a9cb 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Pet.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -437,6 +442,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/PetWithRequiredTags.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/PetWithRequiredTags.java index 5e90ae0d3770..c094150f27e3 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/PetWithRequiredTags.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/PetWithRequiredTags.java @@ -122,6 +122,11 @@ public StatusEnum read(final JsonReader jsonReader) throws IOException { return StatusEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_STATUS = "status"; @@ -434,6 +439,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Zebra.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Zebra.java index 1e5c2608f2a8..33e9757e4d20 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Zebra.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Zebra.java @@ -98,6 +98,11 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { return TypeEnum.fromValue(value); } } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + TypeEnum.fromValue(value); + } } public static final String SERIALIZED_NAME_TYPE = "type"; @@ -277,6 +282,10 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti 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())); } + // validate the optional field `type` + if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) { + TypeEnum.validateJsonElement(jsonObj.get("type")); + } if (!jsonObj.get("className").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `className` to be a primitive type in the JSON string but got `%s`", jsonObj.get("className").toString())); }