diff --git a/docs/generators/java.md b/docs/generators/java.md
index 3db0a9bf5ac..2c51f7dfe27 100644
--- a/docs/generators/java.md
+++ b/docs/generators/java.md
@@ -148,6 +148,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
## LANGUAGE PRIMITIVES
+- BigDecimal
- Boolean
- Double
- Float
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
index e53ecf8a4cd..e2fe8187004 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenComposedSchemas.java
@@ -47,6 +47,22 @@ public class CodegenComposedSchemas {
return not;
}
+ public void setAllOf(List allOf) {
+ this.allOf = allOf;
+ }
+
+ public void setOneOf(List oneOf) {
+ this.oneOf = oneOf;
+ }
+
+ public void setAnyOf(List anyOf) {
+ this.anyOf = anyOf;
+ }
+
+ public void setNot(CodegenProperty not) {
+ this.not = not;
+ }
+
public String toString() {
final StringBuilder sb = new StringBuilder("CodegenComposedSchemas{");
sb.append("oneOf=").append(oneOf);
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
index 6e4adf5809f..0e2f2b4bc7c 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
@@ -39,6 +39,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
+import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -190,6 +191,8 @@ public class JavaClientCodegen extends AbstractJavaCodegen
modelPackage = "org.openapitools.client.model";
rootJavaEEPackage = MICROPROFILE_REST_CLIENT_DEFAULT_ROOT_PACKAGE;
+ languageSpecificPrimitives.add("BigDecimal");
+
// cliOptions default redefinition need to be updated
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
@@ -1019,6 +1022,16 @@ public class JavaClientCodegen extends AbstractJavaCodegen
return codegenModel;
}
+ @Override
+ protected boolean needToImport(String type) {
+ // add import for BigDecimal explicitly since it is a primitive type
+ if("BigDecimal".equals(type)) {
+ return true;
+ }
+
+ return super.needToImport(type) && !type.contains(".");
+ }
+
@Override
public ModelsMap postProcessModelsEnum(ModelsMap objs) {
objs = super.postProcessModelsEnum(objs);
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache
index 1bbf0f0fc8d..333dfbd81cf 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache
@@ -70,7 +70,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
@Override
public {{classname}} read(JsonReader in) throws IOException {
Object deserialized = null;
- JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject();
+ JsonElement jsonElement = elementAdapter.read(in);
{{#useOneOfDiscriminatorLookup}}
{{#discriminator}}
@@ -80,7 +80,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
switch (discriminatorValue) {
{{#mappedModels}}
case "{{{mappingName}}}":
- deserialized = adapter{{modelName}}.fromJsonTree(jsonObject);
+ deserialized = adapter{{modelName}}.fromJsonTree(jsonElement);
new{{classname}}.setActualInstance(deserialized);
return new{{classname}};
{{/mappedModels}}
@@ -94,10 +94,10 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
// deserialize {{{.}}}
try {
// validate the JSON object to see if any exception is thrown
- {{.}}.validateJsonObject(jsonObject);
+ {{.}}.validateJsonElement(jsonElement);
log.log(Level.FINER, "Input data matches schema '{{{.}}}'");
{{classname}} ret = new {{classname}}();
- ret.setActualInstance(adapter{{.}}.fromJsonTree(jsonObject));
+ ret.setActualInstance(adapter{{.}}.fromJsonTree(jsonElement));
return ret;
} catch (Exception e) {
// deserialization failed, continue
@@ -106,7 +106,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
{{/anyOf}}
- throw new IOException(String.format("Failed deserialization for {{classname}}: no class matched. JSON: %s", jsonObject.toString()));
+ throw new IOException(String.format("Failed deserialization for {{classname}}: no class matched. JSON: %s", jsonElement.toString()));
}
}.nullSafe();
}
@@ -190,18 +190,18 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
{{/anyOf}}
/**
- * 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 {{classname}}
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to {{classname}}
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
// validate anyOf schemas one by one
int validCount = 0;
{{#anyOf}}
// validate the json string with {{{.}}}
try {
- {{{.}}}.validateJsonObject(jsonObj);
+ {{{.}}}.validateJsonElement(jsonElement);
return; // return earlier as at least one schema is valid with respect to the Json object
//validCount++;
} catch (Exception e) {
@@ -209,7 +209,7 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
}
{{/anyOf}}
if (validCount == 0) {
- throw new IOException(String.format("The JSON string is invalid for {{classname}} with anyOf schemas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. JSON: %s", jsonObj.toString()));
+ throw new IOException(String.format("The JSON string is invalid for {{classname}} with anyOf schemas: {{#anyOf}}{{{.}}}{{^-last}}, {{/-last}}{{/anyOf}}. JSON: %s", jsonElement.toString()));
}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
index dfe8bf015e7..fc817fbbf0d 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/oneof_model.mustache
@@ -8,6 +8,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import com.google.gson.Gson;
@@ -27,6 +28,7 @@ import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import com.google.gson.JsonArray;
import com.google.gson.JsonParseException;
import {{invokerPackage}}.JSON;
@@ -43,9 +45,18 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
return null; // this class only serializes '{{classname}}' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
+ {{#composedSchemas}}
{{#oneOf}}
- final TypeAdapter<{{.}}> adapter{{.}} = gson.getDelegateAdapter(this, TypeToken.get({{.}}.class));
+ {{^isArray}}
+ final TypeAdapter<{{{dataType}}}> adapter{{{dataType}}} = gson.getDelegateAdapter(this, TypeToken.get({{{dataType}}}.class));
+ {{/isArray}}
+ {{#isArray}}
+
+ final Type typeInstance = new TypeToken>(){}.getType();
+ final TypeAdapter<{{{dataType}}}> adapter{{complexType}}List = (TypeAdapter>) gson.getDelegateAdapter(this, TypeToken.get(typeInstance));
+ {{/isArray}}
{{/oneOf}}
+ {{/composedSchemas}}
return (TypeAdapter) new TypeAdapter<{{classname}}>() {
@Override
@@ -55,25 +66,45 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
return;
}
+ {{#composedSchemas}}
{{#oneOf}}
- // check if the actual instance is of the type `{{.}}`
- if (value.getActualInstance() instanceof {{.}}) {
- JsonObject obj = adapter{{.}}.toJsonTree(({{.}})value.getActualInstance()).getAsJsonObject();
- elementAdapter.write(out, obj);
+ // check if the actual instance is of the type `{{{dataType}}}`
+ if (value.getActualInstance() instanceof {{#isArray}}List>{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}) {
+ {{#isPrimitiveType}}
+ JsonPrimitive primitive = adapter{{{dataType}}}.toJsonTree(({{{dataType}}})value.getActualInstance()).getAsJsonPrimitive();
+ elementAdapter.write(out, primitive);
+ return;
+ {{/isPrimitiveType}}
+ {{#isArray}}
+ List> list = (List>) value.getActualInstance();
+ if(list.get(0) instanceof {{complexType}}) {
+ JsonArray array = adapter{{{complexType}}}List.toJsonTree(({{{dataType}}})value.getActualInstance()).getAsJsonArray();
+ elementAdapter.write(out, array);
return;
+ }
+ {{/isArray}}
+ {{^isArray}}
+ {{^isPrimitiveType}}
+ JsonElement element = adapter{{{dataType}}}.toJsonTree(({{{dataType}}})value.getActualInstance());
+ elementAdapter.write(out, element);
+ return;
+ {{/isPrimitiveType}}
+ {{/isArray}}
}
-
{{/oneOf}}
+ {{/composedSchemas}}
throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}");
}
@Override
public {{classname}} read(JsonReader in) throws IOException {
Object deserialized = null;
- JsonObject jsonObject = elementAdapter.read(in).getAsJsonObject();
+ JsonElement jsonElement = elementAdapter.read(in);
{{#useOneOfDiscriminatorLookup}}
{{#discriminator}}
+ JsonObject jsonObject = jsonElement.getAsJsonObject();
+
// use discriminator value for faster oneOf lookup
{{classname}} new{{classname}} = new {{classname}}();
if (jsonObject.get("{{{propertyBaseName}}}") == null) {
@@ -98,11 +129,58 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
ArrayList errorMessages = new ArrayList<>();
TypeAdapter actualAdapter = elementAdapter;
+ {{#composedSchemas}}
{{#oneOf}}
+ {{^hasVars}}
+ // deserialize {{{dataType}}}
+ try {
+ // validate the JSON object to see if any exception is thrown
+ {{#isPrimitiveType}}
+ if(!jsonElement.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
+ throw new IllegalArgumentException(String.format("Expected json element to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
+ }
+ actualAdapter = adapter{{{dataType}}};
+ {{/isPrimitiveType}}
+ {{^isPrimitiveType}}
+ {{^isArray}}
+ {{{dataType}}}.validateJsonElement(jsonElement);
+ actualAdapter = adapter{{{dataType}}};
+ {{/isArray}}
+ {{/isPrimitiveType}}
+ {{#isArray}}
+ if (!jsonElement.isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString()));
+ }
+
+ JsonArray array = jsonElement.getAsJsonArray();
+ // validate array items
+ for(JsonElement element : array) {
+ {{#items}}
+ {{#isPrimitiveType}}
+ if(!element.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
+ throw new IllegalArgumentException(String.format("Expected array items to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
+ }
+ {{/isPrimitiveType}}
+ {{^isPrimitiveType}}
+ {{{dataType}}}.validateJsonElement(element);
+ {{/isPrimitiveType}}
+ {{/items}}
+ }
+ actualAdapter = adapter{{{complexType}}}List;
+ {{/isArray}}
+ match++;
+ log.log(Level.FINER, "Input data matches schema '{{{dataType}}}'");
+ } catch (Exception e) {
+ // deserialization failed, continue
+ errorMessages.add(String.format("Deserialization for {{{dataType}}} failed with `%s`.", e.getMessage()));
+ log.log(Level.FINER, "Input data does not match schema '{{{dataType}}}'", e);
+ }
+ {{/hasVars}}
+ {{#hasVars}}
// deserialize {{{.}}}
try {
// validate the JSON object to see if any exception is thrown
- {{.}}.validateJsonObject(jsonObject);
+ {{.}}.validateJsonElement(jsonElement);
actualAdapter = adapter{{.}};
match++;
log.log(Level.FINER, "Input data matches schema '{{{.}}}'");
@@ -111,15 +189,17 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
errorMessages.add(String.format("Deserialization for {{{.}}} failed with `%s`.", e.getMessage()));
log.log(Level.FINER, "Input data does not match schema '{{{.}}}'", e);
}
-
+ {{/hasVars}}
{{/oneOf}}
+ {{/composedSchemas}}
+
if (match == 1) {
{{classname}} ret = new {{classname}}();
- ret.setActualInstance(actualAdapter.fromJsonTree(jsonObject));
+ ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
return ret;
}
- throw new IOException(String.format("Failed deserialization for {{classname}}: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonObject.toString()));
+ throw new IOException(String.format("Failed deserialization for {{classname}}: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString()));
}
}.nullSafe();
}
@@ -140,9 +220,11 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
{{/oneOf}}
static {
+ {{#composedSchemas}}
{{#oneOf}}
- schemas.put("{{{.}}}", {{{.}}}.class);
+ schemas.put("{{{dataType}}}", {{{baseType}}}.class);
{{/oneOf}}
+ {{/composedSchemas}}
}
@Override
@@ -167,13 +249,24 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
}
{{/isNullable}}
+ {{#composedSchemas}}
{{#oneOf}}
- if (instance instanceof {{{.}}}) {
+ if (instance instanceof {{#isArray}}List>{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}) {
+ {{#isArray}}
+ List> list = (List>) instance;
+ if(list.get(0) instanceof {{complexType}}) {
+ super.setActualInstance(instance);
+ return;
+ }
+ {{/isArray}}
+ {{^isArray}}
super.setActualInstance(instance);
return;
+ {{/isArray}}
}
{{/oneOf}}
+ {{/composedSchemas}}
throw new RuntimeException("Invalid instance type. Must be {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}");
}
@@ -188,42 +281,79 @@ public class {{classname}} extends AbstractOpenApiSchema{{#vendorExtensions.x-im
return super.getActualInstance();
}
+ {{#composedSchemas}}
{{#oneOf}}
/**
- * Get the actual instance of `{{{.}}}`. If the actual instance is not `{{{.}}}`,
+ * Get the actual instance of `{{{dataType}}}`. If the actual instance is not `{{{dataType}}}`,
* the ClassCastException will be thrown.
*
- * @return The actual instance of `{{{.}}}`
- * @throws ClassCastException if the instance is not `{{{.}}}`
+ * @return The actual instance of `{{{dataType}}}`
+ * @throws ClassCastException if the instance is not `{{{dataType}}}`
*/
- public {{{.}}} get{{{.}}}() throws ClassCastException {
- return ({{{.}}})super.getActualInstance();
+ public {{{dataType}}} get{{#isArray}}{{complexType}}List{{/isArray}}{{^isArray}}{{{dataType}}}{{/isArray}}() throws ClassCastException {
+ return ({{{dataType}}})super.getActualInstance();
}
-
{{/oneOf}}
+ {{/composedSchemas}}
/**
- * 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 {{classname}}
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to {{classname}}
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
// validate oneOf schemas one by one
int validCount = 0;
ArrayList errorMessages = new ArrayList<>();
+ {{#composedSchemas}}
{{#oneOf}}
- // validate the json string with {{{.}}}
+ // validate the json string with {{{dataType}}}
try {
- {{{.}}}.validateJsonObject(jsonObj);
+ {{^hasVars}}
+ {{#isPrimitiveType}}
+ if(!jsonElement.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
+ throw new IllegalArgumentException(String.format("Expected json element to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
+ }
+ {{/isPrimitiveType}}
+ {{^isPrimitiveType}}
+ {{^isArray}}
+ {{{dataType}}}.validateJsonElement(jsonElement);
+ {{/isArray}}
+ {{/isPrimitiveType}}
+ {{#isArray}}
+ if (!jsonElement.isJsonArray()) {
+ throw new IllegalArgumentException(String.format("Expected json element to be a array type in the JSON string but got `%s`", jsonElement.toString()));
+ }
+ JsonArray array = jsonElement.getAsJsonArray();
+ // validate array items
+ for(JsonElement element : array) {
+ {{#items}}
+ {{#isPrimitiveType}}
+ if(!element.getAsJsonPrimitive().is{{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}}()) {
+ throw new IllegalArgumentException(String.format("Expected array items to be of type {{#isBoolean}}Boolean{{/isBoolean}}{{#isString}}String{{/isString}}{{^isString}}{{^isBoolean}}Number{{/isBoolean}}{{/isString}} in the JSON string but got `%s`", jsonElement.toString()));
+ }
+ {{/isPrimitiveType}}
+ {{^isPrimitiveType}}
+ {{{dataType}}}.validateJsonElement(element);
+ {{/isPrimitiveType}}
+ {{/items}}
+ }
+ {{/isArray}}
+ {{/hasVars}}
+ {{#hasVars}}
+ {{{.}}}.validateJsonElement(jsonElement);
+ validCount++;
+ {{/hasVars}}
validCount++;
} catch (Exception e) {
- errorMessages.add(String.format("Deserialization for {{{.}}} failed with `%s`.", e.getMessage()));
+ errorMessages.add(String.format("Deserialization for {{{dataType}}} failed with `%s`.", e.getMessage()));
// continue to the next one
}
{{/oneOf}}
+ {{/composedSchemas}}
if (validCount != 1) {
- throw new IOException(String.format("The JSON string is invalid for {{classname}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonObj.toString()));
+ throw new IOException(String.format("The JSON string is invalid for {{classname}} with oneOf schemas: {{#oneOf}}{{{.}}}{{^-last}}, {{/-last}}{{/oneOf}}. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString()));
}
}
diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
index 117f08da9b4..a42ad9f60ae 100644
--- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
+++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pojo.mustache
@@ -448,25 +448,25 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
}
/**
- * 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 {{classname}}
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to {{classname}}
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!{{classname}}.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!{{classname}}.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in {{{classname}}} is not found in the empty JSON string", {{classname}}.openapiRequiredFields.toString()));
}
}
{{^hasChildren}}
{{^isAdditionalPropertiesTrue}}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!{{classname}}.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `{{classname}}` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `{{classname}}` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
{{/isAdditionalPropertiesTrue}}
@@ -475,14 +475,17 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : {{classname}}.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()));
}
}
{{/-first}}
{{/requiredVars}}
{{/hasChildren}}
{{^discriminator}}
+ {{#hasVars}}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
+ {{/hasVars}}
{{#vars}}
{{#isArray}}
{{#items.isModel}}
@@ -495,7 +498,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
JsonArray jsonArray{{name}} = jsonObj.getAsJsonArray("{{{baseName}}}");
// validate the required field `{{{baseName}}}` (array)
for (int i = 0; i < jsonArray{{name}}.size(); i++) {
- {{{items.dataType}}}.validateJsonObject(jsonArray{{name}}.get(i).getAsJsonObject());
+ {{{items.dataType}}}.validateJsonElement(jsonArray{{name}}.get(i));
};
{{/required}}
{{^required}}
@@ -509,7 +512,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
// validate the optional field `{{{baseName}}}` (array)
for (int i = 0; i < jsonArray{{name}}.size(); i++) {
- {{{items.dataType}}}.validateJsonObject(jsonArray{{name}}.get(i).getAsJsonObject());
+ {{{items.dataType}}}.validateJsonElement(jsonArray{{name}}.get(i));
};
}
}
@@ -541,12 +544,12 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#isModel}}
{{#required}}
// validate the required field `{{{baseName}}}`
- {{{dataType}}}.validateJsonObject(jsonObj.getAsJsonObject("{{{baseName}}}"));
+ {{{dataType}}}.validateJsonElement(jsonObj.get("{{{baseName}}}"));
{{/required}}
{{^required}}
// validate the optional field `{{{baseName}}}`
if (jsonObj.get("{{{baseName}}}") != null && !jsonObj.get("{{{baseName}}}").isJsonNull()) {
- {{{dataType}}}.validateJsonObject(jsonObj.getAsJsonObject("{{{baseName}}}"));
+ {{{dataType}}}.validateJsonElement(jsonObj.get("{{{baseName}}}"));
}
{{/required}}
{{/isModel}}
@@ -556,11 +559,11 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#hasChildren}}
{{#discriminator}}
- String discriminatorValue = jsonObj.get("{{{propertyBaseName}}}").getAsString();
+ String discriminatorValue = jsonElement.getAsJsonObject().get("{{{propertyBaseName}}}").getAsString();
switch (discriminatorValue) {
{{#mappedModels}}
case "{{mappingName}}":
- {{modelName}}.validateJsonObject(jsonObj);
+ {{modelName}}.validateJsonElement(jsonElement);
break;
{{/mappedModels}}
default:
@@ -610,9 +613,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
@Override
public {{classname}} read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
{{#isAdditionalPropertiesTrue}}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
{{classname}} instance = thisAdapter.fromJsonTree(jsonObj);
for (Map.Entry entry : jsonObj.entrySet()) {
@@ -636,7 +640,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
return instance;
{{/isAdditionalPropertiesTrue}}
{{^isAdditionalPropertiesTrue}}
- return thisAdapter.fromJsonTree(jsonObj);
+ return thisAdapter.fromJsonTree(jsonElement);
{{/isAdditionalPropertiesTrue}}
}
diff --git a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml
index 0008870a205..0b1b7f8fff6 100644
--- a/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml
+++ b/modules/openapi-generator/src/test/resources/3_0/java/petstore-with-fake-endpoints-models-for-testing-okhttp-gson.yaml
@@ -1109,6 +1109,22 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ArrayOfEnums'
+ /values:
+ get:
+ tags:
+ - values
+ summary: Get some primitive variable values
+ description: ''
+ operationId: getSomeValues
+ responses:
+ '200':
+ description: successful operation
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Variable'
+ '400':
+ description: Invalid Value
servers:
- url: 'http://{server}.swagger.io:{port}/v2'
description: petstore server
@@ -2224,3 +2240,31 @@ components:
items:
type: string
type: array
+ Variable:
+ description: Value object
+ properties:
+ name:
+ type: string
+ example: 'variable_1'
+ value:
+ $ref: '#/components/schemas/Value'
+ required:
+ - name
+ - value
+ Value:
+ oneOf:
+ - $ref: '#/components/schemas/Scalar'
+ - $ref: '#/components/schemas/Array'
+ Scalar:
+ description: Values of scalar type
+ oneOf:
+ - type: string
+ maxLength: 1089
+ - type: number
+ - type: boolean
+ Array:
+ description: Values of array type
+ type: array
+ minItems: 1
+ items:
+ $ref: '#/components/schemas/Scalar'
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java
index a82e2f41f24..d57f30a4ea3 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Bird.java
@@ -160,25 +160,26 @@ public class Bird {
}
/**
- * 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 Bird
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Bird
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Bird.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Bird.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Bird is not found in the empty JSON string", Bird.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Bird.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Bird` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Bird` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("size") != null && !jsonObj.get("size").isJsonNull()) && !jsonObj.get("size").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `size` to be a primitive type in the JSON string but got `%s`", jsonObj.get("size").toString()));
}
@@ -207,9 +208,9 @@ public class Bird {
@Override
public Bird read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java
index 58e377cc406..ec76051b063 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Category.java
@@ -160,25 +160,26 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Category.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -204,9 +205,9 @@ public class Category {
@Override
public Category read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java
index acc697cb904..65f02cee3b1 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/DataQuery.java
@@ -196,25 +196,26 @@ public class DataQuery extends Query {
}
/**
- * 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 DataQuery
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to DataQuery
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!DataQuery.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!DataQuery.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in DataQuery is not found in the empty JSON string", DataQuery.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!DataQuery.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DataQuery` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DataQuery` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("suffix") != null && !jsonObj.get("suffix").isJsonNull()) && !jsonObj.get("suffix").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `suffix` to be a primitive type in the JSON string but got `%s`", jsonObj.get("suffix").toString()));
}
@@ -243,9 +244,9 @@ public class DataQuery extends Query {
@Override
public DataQuery read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 dff9b07ffb2..8de8e55d001 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
@@ -448,25 +448,26 @@ public class DefaultValue {
}
/**
- * 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 DefaultValue
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to DefaultValue
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!DefaultValue.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!DefaultValue.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in DefaultValue is not found in the empty JSON string", DefaultValue.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!DefaultValue.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DefaultValue` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `DefaultValue` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("array_string_enum_ref_default") != null && !jsonObj.get("array_string_enum_ref_default").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `array_string_enum_ref_default` to be an array in the JSON string but got `%s`", jsonObj.get("array_string_enum_ref_default").toString()));
@@ -520,9 +521,9 @@ public class DefaultValue {
@Override
public DefaultValue read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java
index 96eca50f8e8..7a346582ee7 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/NumberPropertiesOnly.java
@@ -191,25 +191,26 @@ public class NumberPropertiesOnly {
}
/**
- * 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 NumberPropertiesOnly
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to NumberPropertiesOnly
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!NumberPropertiesOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!NumberPropertiesOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in NumberPropertiesOnly is not found in the empty JSON string", NumberPropertiesOnly.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!NumberPropertiesOnly.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberPropertiesOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberPropertiesOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@@ -232,9 +233,9 @@ public class NumberPropertiesOnly {
@Override
public NumberPropertiesOnly read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 0944584ff25..c24315dbc3f 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
@@ -343,38 +343,39 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Pet.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonElement.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();
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()));
}
// validate the optional field `category`
if (jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) {
- Category.validateJsonObject(jsonObj.getAsJsonObject("category"));
+ Category.validateJsonElement(jsonObj.get("category"));
}
// ensure the required json array is present
if (jsonObj.get("photoUrls") == null) {
@@ -392,7 +393,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));
};
}
}
@@ -421,9 +422,9 @@ public class Pet {
@Override
public Pet read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 e802c8b7fdd..097316adcf4 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
@@ -219,17 +219,18 @@ public class Query {
}
/**
- * 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 Query
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Query
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Query.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Query.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Query is not found in the empty JSON string", Query.openapiRequiredFields.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("outcomes") != null && !jsonObj.get("outcomes").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `outcomes` to be an array in the JSON string but got `%s`", jsonObj.get("outcomes").toString()));
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Tag.java
index 3ac9a7272de..399769cb396 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Tag.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/Tag.java
@@ -160,25 +160,26 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Tag.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -204,9 +205,9 @@ public class Tag {
@Override
public Tag read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
index 649d7a2cccf..91003749d8f 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.java
@@ -216,25 +216,26 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
}
/**
- * 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 TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter is not found in the empty JSON string", TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("size") != null && !jsonObj.get("size").isJsonNull()) && !jsonObj.get("size").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `size` to be a primitive type in the JSON string but got `%s`", jsonObj.get("size").toString()));
}
@@ -266,9 +267,9 @@ public class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
@Override
public TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
index 156118d002e..8bd134c79ee 100644
--- a/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
+++ b/samples/client/echo_api/java/okhttp-gson/src/main/java/org/openapitools/client/model/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.java
@@ -142,25 +142,26 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
}
/**
- * 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 TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter is not found in the empty JSON string", TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("values") != null && !jsonObj.get("values").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `values` to be an array in the JSON string but got `%s`", jsonObj.get("values").toString()));
@@ -187,9 +188,9 @@ public class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter {
@Override
public TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 badbbc828d1..d52b087d3e9 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
@@ -289,25 +289,26 @@ public class SomeObj {
}
/**
- * 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 SomeObj
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to SomeObj
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!SomeObj.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!SomeObj.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in SomeObj is not found in the empty JSON string", SomeObj.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!SomeObj.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SomeObj` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SomeObj` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -339,9 +340,9 @@ public class SomeObj {
@Override
public SomeObj read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md b/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md
index 6eb12aee357..68b521a0cfe 100644
--- a/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md
+++ b/samples/client/petstore/java/apache-httpclient/docs/FakeApi.md
@@ -396,7 +396,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
index 1b9d42f423a..45bbe45dbe5 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
@@ -148,15 +148,13 @@ public class ArrayOfArrayOfNumberOnly {
// add `ArrayArrayNumber` to the URL query string
if (getArrayArrayNumber() != null) {
for (int i = 0; i < getArrayArrayNumber().size(); i++) {
- if (getArrayArrayNumber().get(i) != null) {
- try {
- joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
- "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
- URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
- } catch (UnsupportedEncodingException e) {
- // Should never happen, UTF-8 is always supported
- throw new RuntimeException(e);
- }
+ try {
+ joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
}
}
}
diff --git a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
index 2cea68ab8b4..2e3e4c1d458 100644
--- a/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/apache-httpclient/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
@@ -148,15 +148,13 @@ public class ArrayOfNumberOnly {
// add `ArrayNumber` to the URL query string
if (getArrayNumber() != null) {
for (int i = 0; i < getArrayNumber().size(); i++) {
- if (getArrayNumber().get(i) != null) {
- try {
- joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
- "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
- URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
- } catch (UnsupportedEncodingException e) {
- // Should never happen, UTF-8 is always supported
- throw new RuntimeException(e);
- }
+ try {
+ joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), "UTF-8").replaceAll("\\+", "%20")));
+ } catch (UnsupportedEncodingException e) {
+ // Should never happen, UTF-8 is always supported
+ throw new RuntimeException(e);
}
}
}
diff --git a/samples/client/petstore/java/google-api-client/docs/FakeApi.md b/samples/client/petstore/java/google-api-client/docs/FakeApi.md
index 627366e41db..829724b750d 100644
--- a/samples/client/petstore/java/google-api-client/docs/FakeApi.md
+++ b/samples/client/petstore/java/google-api-client/docs/FakeApi.md
@@ -266,7 +266,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/jersey1/docs/FakeApi.md b/samples/client/petstore/java/jersey1/docs/FakeApi.md
index 627366e41db..829724b750d 100644
--- a/samples/client/petstore/java/jersey1/docs/FakeApi.md
+++ b/samples/client/petstore/java/jersey1/docs/FakeApi.md
@@ -266,7 +266,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/jersey2-java8-localdatetime/docs/FakeApi.md b/samples/client/petstore/java/jersey2-java8-localdatetime/docs/FakeApi.md
index d21432dbf3e..277a09f049f 100644
--- a/samples/client/petstore/java/jersey2-java8-localdatetime/docs/FakeApi.md
+++ b/samples/client/petstore/java/jersey2-java8-localdatetime/docs/FakeApi.md
@@ -264,7 +264,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md b/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md
index 84167f65462..3d7d6254677 100644
--- a/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md
+++ b/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md
@@ -264,7 +264,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/jersey3/docs/FakeApi.md b/samples/client/petstore/java/jersey3/docs/FakeApi.md
index 0663bb791e4..2fa172a50ba 100644
--- a/samples/client/petstore/java/jersey3/docs/FakeApi.md
+++ b/samples/client/petstore/java/jersey3/docs/FakeApi.md
@@ -260,7 +260,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/native-async/docs/FakeApi.md b/samples/client/petstore/java/native-async/docs/FakeApi.md
index eabbd418b17..eea0ccef720 100644
--- a/samples/client/petstore/java/native-async/docs/FakeApi.md
+++ b/samples/client/petstore/java/native-async/docs/FakeApi.md
@@ -640,7 +640,7 @@ public class Example {
### Return type
-CompletableFuture<[**BigDecimal**](BigDecimal.md)>
+CompletableFuture<**BigDecimal**>
### Authorization
@@ -716,7 +716,7 @@ public class Example {
### Return type
-CompletableFuture>
+CompletableFuture>
### Authorization
diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
index 856d6942ae8..e7ae0bcade9 100644
--- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
@@ -153,11 +153,9 @@ public class ArrayOfArrayOfNumberOnly {
// add `ArrayArrayNumber` to the URL query string
if (getArrayArrayNumber() != null) {
for (int i = 0; i < getArrayArrayNumber().size(); i++) {
- if (getArrayArrayNumber().get(i) != null) {
- joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
- "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
- URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
- }
+ joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
diff --git a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
index 6986ea26644..7b20ae0d924 100644
--- a/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/native-async/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
@@ -153,11 +153,9 @@ public class ArrayOfNumberOnly {
// add `ArrayNumber` to the URL query string
if (getArrayNumber() != null) {
for (int i = 0; i < getArrayNumber().size(); i++) {
- if (getArrayNumber().get(i) != null) {
- joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
- "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
- URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
- }
+ joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
diff --git a/samples/client/petstore/java/native/docs/FakeApi.md b/samples/client/petstore/java/native/docs/FakeApi.md
index e8911736308..91d80311ed4 100644
--- a/samples/client/petstore/java/native/docs/FakeApi.md
+++ b/samples/client/petstore/java/native/docs/FakeApi.md
@@ -603,7 +603,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
@@ -671,7 +671,7 @@ public class Example {
### Return type
-ApiResponse<[**BigDecimal**](BigDecimal.md)>
+ApiResponse<**BigDecimal**>
### Authorization
diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
index 856d6942ae8..e7ae0bcade9 100644
--- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
@@ -153,11 +153,9 @@ public class ArrayOfArrayOfNumberOnly {
// add `ArrayArrayNumber` to the URL query string
if (getArrayArrayNumber() != null) {
for (int i = 0; i < getArrayArrayNumber().size(); i++) {
- if (getArrayArrayNumber().get(i) != null) {
- joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
- "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
- URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
- }
+ joiner.add(String.format("%sArrayArrayNumber%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
diff --git a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
index 6986ea26644..7b20ae0d924 100644
--- a/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/native/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
@@ -153,11 +153,9 @@ public class ArrayOfNumberOnly {
// add `ArrayNumber` to the URL query string
if (getArrayNumber() != null) {
for (int i = 0; i < getArrayNumber().size(); i++) {
- if (getArrayNumber().get(i) != null) {
- joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
- "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
- URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
- }
+ joiner.add(String.format("%sArrayNumber%s%s=%s", prefix, suffix,
+ "".equals(suffix) ? "" : String.format("%s%d%s", containerPrefix, i, containerSuffix),
+ URLEncoder.encode(String.valueOf(getArrayNumber().get(i)), StandardCharsets.UTF_8).replaceAll("\\+", "%20")));
}
}
diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java
index 3ecdbda0716..5aef445f0cf 100644
--- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java
+++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Category.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java
index 135ecf70fc0..f4f09dbfb17 100644
--- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java
+++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/ModelApiResponse.java
@@ -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 entry : jsonObj.entrySet()) {
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 f5abae46523..004059b8f76 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
@@ -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 entry : jsonObj.entrySet()) {
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 39ba8d3643f..54d44c9c469 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
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java
index 9c1f9247b1b..97fe598e2e1 100644
--- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java
+++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/Tag.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java
index 2008add2959..f7aa406f479 100644
--- a/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java
+++ b/samples/client/petstore/java/okhttp-gson-awsv4signature/src/main/java/org/openapitools/client/model/User.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/FakeApi.md
index 98f0b0098b8..0736ffc044d 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/FakeApi.md
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/docs/FakeApi.md
@@ -251,7 +251,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
index 62ee8304532..38302f996d3 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
@@ -132,25 +132,26 @@ public class AdditionalPropertiesAnyType {
}
/**
- * 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 AdditionalPropertiesAnyType
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesAnyType
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesAnyType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesAnyType.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesAnyType.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -176,9 +177,9 @@ public class AdditionalPropertiesAnyType {
@Override
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
index 7055b32a017..5252f9e9f37 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
@@ -133,25 +133,26 @@ public class AdditionalPropertiesArray {
}
/**
- * 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 AdditionalPropertiesArray
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesArray
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesArray.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesArray.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesArray.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -177,9 +178,9 @@ public class AdditionalPropertiesArray {
@Override
public AdditionalPropertiesArray read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
index 91d91a38b95..0ab06c7e54d 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
@@ -132,25 +132,26 @@ public class AdditionalPropertiesBoolean {
}
/**
- * 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 AdditionalPropertiesBoolean
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesBoolean
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesBoolean.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesBoolean.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesBoolean.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -176,9 +177,9 @@ public class AdditionalPropertiesBoolean {
@Override
public AdditionalPropertiesBoolean read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
index b27b1a665a8..c1cceca6e56 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
@@ -480,25 +480,26 @@ public class AdditionalPropertiesClass {
}
/**
- * 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 AdditionalPropertiesClass
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesClass
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesClass is not found in the empty JSON string", AdditionalPropertiesClass.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesClass.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@@ -521,9 +522,9 @@ public class AdditionalPropertiesClass {
@Override
public AdditionalPropertiesClass read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java
index 8027268210e..92c9ca7cc50 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java
@@ -132,25 +132,26 @@ public class AdditionalPropertiesInteger {
}
/**
- * 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 AdditionalPropertiesInteger
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesInteger
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesInteger.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesInteger.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesInteger.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -176,9 +177,9 @@ public class AdditionalPropertiesInteger {
@Override
public AdditionalPropertiesInteger read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java
index abe5f4cc555..f786790043b 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java
@@ -133,25 +133,26 @@ public class AdditionalPropertiesNumber {
}
/**
- * 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 AdditionalPropertiesNumber
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesNumber
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesNumber.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesNumber.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesNumber.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -177,9 +178,9 @@ public class AdditionalPropertiesNumber {
@Override
public AdditionalPropertiesNumber read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java
index eb3de7bbd95..8d7686e9800 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java
@@ -133,25 +133,26 @@ public class AdditionalPropertiesObject {
}
/**
- * 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 AdditionalPropertiesObject
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesObject
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesObject.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -177,9 +178,9 @@ public class AdditionalPropertiesObject {
@Override
public AdditionalPropertiesObject read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java
index 7f1bb50e0cf..6dae21f945b 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java
@@ -132,25 +132,26 @@ public class AdditionalPropertiesString {
}
/**
- * 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 AdditionalPropertiesString
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesString
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesString.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesString.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesString.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -176,9 +177,9 @@ public class AdditionalPropertiesString {
@Override
public AdditionalPropertiesString read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Animal.java
index 88b554bbf2b..15e2aa381e6 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Animal.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Animal.java
@@ -162,28 +162,28 @@ public class Animal {
}
/**
- * 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 Animal
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Animal
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Animal.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Animal.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Animal is not found in the empty JSON string", Animal.openapiRequiredFields.toString()));
}
}
- String discriminatorValue = jsonObj.get("className").getAsString();
+ String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString();
switch (discriminatorValue) {
case "BigCat":
- BigCat.validateJsonObject(jsonObj);
+ BigCat.validateJsonElement(jsonElement);
break;
case "Cat":
- Cat.validateJsonObject(jsonObj);
+ Cat.validateJsonElement(jsonElement);
break;
case "Dog":
- Dog.validateJsonObject(jsonObj);
+ Dog.validateJsonElement(jsonElement);
break;
default:
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
index a8de8fc7f56..58141e11d0b 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
@@ -143,25 +143,26 @@ public class ArrayOfArrayOfNumberOnly {
}
/**
- * 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 ArrayOfArrayOfNumberOnly
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ArrayOfArrayOfNumberOnly
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfArrayOfNumberOnly is not found in the empty JSON string", ArrayOfArrayOfNumberOnly.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ArrayOfArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("ArrayArrayNumber") != null && !jsonObj.get("ArrayArrayNumber").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `ArrayArrayNumber` to be an array in the JSON string but got `%s`", jsonObj.get("ArrayArrayNumber").toString()));
@@ -188,9 +189,9 @@ public class ArrayOfArrayOfNumberOnly {
@Override
public ArrayOfArrayOfNumberOnly read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
index 7c9ef3dbb7b..3d05967401c 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
@@ -143,25 +143,26 @@ public class ArrayOfNumberOnly {
}
/**
- * 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 ArrayOfNumberOnly
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ArrayOfNumberOnly
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfNumberOnly is not found in the empty JSON string", ArrayOfNumberOnly.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("ArrayNumber") != null && !jsonObj.get("ArrayNumber").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `ArrayNumber` to be an array in the JSON string but got `%s`", jsonObj.get("ArrayNumber").toString()));
@@ -188,9 +189,9 @@ public class ArrayOfNumberOnly {
@Override
public ArrayOfNumberOnly read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayTest.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayTest.java
index 458a9aa88f9..111d03b71e9 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayTest.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ArrayTest.java
@@ -215,25 +215,26 @@ public class ArrayTest {
}
/**
- * 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 ArrayTest
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ArrayTest
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ArrayTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ArrayTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayTest is not found in the empty JSON string", ArrayTest.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ArrayTest.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("array_of_string") != null && !jsonObj.get("array_of_string").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `array_of_string` to be an array in the JSON string but got `%s`", jsonObj.get("array_of_string").toString()));
@@ -268,9 +269,9 @@ public class ArrayTest {
@Override
public ArrayTest read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 740c2f3b737..fd82762e2e0 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
@@ -191,30 +191,30 @@ public class BigCat extends Cat {
}
/**
- * 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 BigCat
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to BigCat
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!BigCat.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!BigCat.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in BigCat is not found in the empty JSON string", BigCat.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!BigCat.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCat` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCat` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : BigCat.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()));
}
}
}
@@ -239,9 +239,9 @@ public class BigCat extends Cat {
@Override
public BigCat read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Capitalization.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Capitalization.java
index 6eaa2f1b9f8..6bdb7547b8c 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Capitalization.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Capitalization.java
@@ -272,25 +272,26 @@ public class Capitalization {
}
/**
- * 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 Capitalization
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Capitalization
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Capitalization.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Capitalization.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Capitalization is not found in the empty JSON string", Capitalization.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Capitalization.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("smallCamel") != null && !jsonObj.get("smallCamel").isJsonNull()) && !jsonObj.get("smallCamel").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `smallCamel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("smallCamel").toString()));
}
@@ -331,9 +332,9 @@ public class Capitalization {
@Override
public Capitalization read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Cat.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Cat.java
index d5a738f5344..b523a01e230 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Cat.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Cat.java
@@ -139,22 +139,22 @@ public class Cat extends Animal {
}
/**
- * 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 Cat
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Cat
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Cat.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Cat.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Cat is not found in the empty JSON string", Cat.openapiRequiredFields.toString()));
}
}
- String discriminatorValue = jsonObj.get("className").getAsString();
+ String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString();
switch (discriminatorValue) {
case "BigCat":
- BigCat.validateJsonObject(jsonObj);
+ BigCat.validateJsonElement(jsonElement);
break;
default:
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Category.java
index 106fcefb378..bcdcbaa42ef 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Category.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Category.java
@@ -161,32 +161,33 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Category.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : Category.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();
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()));
}
@@ -212,9 +213,9 @@ public class Category {
@Override
public Category read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ClassModel.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ClassModel.java
index 9532dfa3870..61c6ac4e1e9 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ClassModel.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ClassModel.java
@@ -132,25 +132,26 @@ public class ClassModel {
}
/**
- * 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 ClassModel
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ClassModel
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ClassModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ClassModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ClassModel is not found in the empty JSON string", ClassModel.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ClassModel.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("_class") != null && !jsonObj.get("_class").isJsonNull()) && !jsonObj.get("_class").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `_class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("_class").toString()));
}
@@ -176,9 +177,9 @@ public class ClassModel {
@Override
public ClassModel read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Client.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Client.java
index eaf9c719f7b..dd16290d102 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Client.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Client.java
@@ -132,25 +132,26 @@ public class Client {
}
/**
- * 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 Client
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Client
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Client.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Client.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Client is not found in the empty JSON string", Client.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Client.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("client") != null && !jsonObj.get("client").isJsonNull()) && !jsonObj.get("client").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `client` to be a primitive type in the JSON string but got `%s`", jsonObj.get("client").toString()));
}
@@ -176,9 +177,9 @@ public class Client {
@Override
public Client read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Dog.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Dog.java
index 96156f08fe3..b53d263b1e9 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Dog.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Dog.java
@@ -139,30 +139,30 @@ public class Dog extends Animal {
}
/**
- * 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 Dog
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Dog
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Dog.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Dog.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Dog is not found in the empty JSON string", Dog.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Dog.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : Dog.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()));
}
}
}
@@ -187,9 +187,9 @@ public class Dog extends Animal {
@Override
public Dog read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 9980488e8ec..92fa18a6c13 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
@@ -264,25 +264,26 @@ public class EnumArrays {
}
/**
- * 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 EnumArrays
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to EnumArrays
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!EnumArrays.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!EnumArrays.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumArrays is not found in the empty JSON string", EnumArrays.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!EnumArrays.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
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()));
}
@@ -312,9 +313,9 @@ public class EnumArrays {
@Override
public EnumArrays read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 f63987dac1c..b279ba5012d 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
@@ -438,32 +438,33 @@ public class EnumTest {
}
/**
- * 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 EnumTest
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to EnumTest
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!EnumTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!EnumTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumTest is not found in the empty JSON string", EnumTest.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!EnumTest.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : EnumTest.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();
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()));
}
@@ -492,9 +493,9 @@ public class EnumTest {
@Override
public EnumTest read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
index 4505754cafe..ed74eecc4bc 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FileSchemaTestClass.java
@@ -171,28 +171,29 @@ public class FileSchemaTestClass {
}
/**
- * 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 FileSchemaTestClass
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to FileSchemaTestClass
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!FileSchemaTestClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!FileSchemaTestClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in FileSchemaTestClass is not found in the empty JSON string", FileSchemaTestClass.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!FileSchemaTestClass.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileSchemaTestClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FileSchemaTestClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// validate the optional field `file`
if (jsonObj.get("file") != null && !jsonObj.get("file").isJsonNull()) {
- ModelFile.validateJsonObject(jsonObj.getAsJsonObject("file"));
+ ModelFile.validateJsonElement(jsonObj.get("file"));
}
if (jsonObj.get("files") != null && !jsonObj.get("files").isJsonNull()) {
JsonArray jsonArrayfiles = jsonObj.getAsJsonArray("files");
@@ -204,7 +205,7 @@ public class FileSchemaTestClass {
// validate the optional field `files` (array)
for (int i = 0; i < jsonArrayfiles.size(); i++) {
- ModelFile.validateJsonObject(jsonArrayfiles.get(i).getAsJsonObject());
+ ModelFile.validateJsonElement(jsonArrayfiles.get(i));
};
}
}
@@ -230,9 +231,9 @@ public class FileSchemaTestClass {
@Override
public FileSchemaTestClass read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FormatTest.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FormatTest.java
index d8b97517934..bbe855488fd 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FormatTest.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/FormatTest.java
@@ -515,32 +515,33 @@ public class FormatTest {
}
/**
- * 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 FormatTest
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to FormatTest
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!FormatTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!FormatTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in FormatTest is not found in the empty JSON string", FormatTest.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!FormatTest.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FormatTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FormatTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : FormatTest.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();
if ((jsonObj.get("string") != null && !jsonObj.get("string").isJsonNull()) && !jsonObj.get("string").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string").toString()));
}
@@ -572,9 +573,9 @@ public class FormatTest {
@Override
public FormatTest read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java
index e6c2d774dac..23889a40b13 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/HasOnlyReadOnly.java
@@ -152,25 +152,26 @@ public class HasOnlyReadOnly {
}
/**
- * 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 HasOnlyReadOnly
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to HasOnlyReadOnly
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!HasOnlyReadOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!HasOnlyReadOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in HasOnlyReadOnly is not found in the empty JSON string", HasOnlyReadOnly.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!HasOnlyReadOnly.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HasOnlyReadOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `HasOnlyReadOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("bar") != null && !jsonObj.get("bar").isJsonNull()) && !jsonObj.get("bar").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `bar` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bar").toString()));
}
@@ -199,9 +200,9 @@ public class HasOnlyReadOnly {
@Override
public HasOnlyReadOnly read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 77765a85fcc..36e9d8420c1 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
@@ -297,25 +297,26 @@ public class MapTest {
}
/**
- * 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 MapTest
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to MapTest
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!MapTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!MapTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in MapTest is not found in the empty JSON string", MapTest.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!MapTest.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MapTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MapTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@@ -338,9 +339,9 @@ public class MapTest {
@Override
public MapTest read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
index 7037c8bb425..abc1913bc31 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
@@ -201,25 +201,26 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
}
/**
- * 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 MixedPropertiesAndAdditionalPropertiesClass
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to MixedPropertiesAndAdditionalPropertiesClass
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in MixedPropertiesAndAdditionalPropertiesClass is not found in the empty JSON string", MixedPropertiesAndAdditionalPropertiesClass.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!MixedPropertiesAndAdditionalPropertiesClass.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MixedPropertiesAndAdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MixedPropertiesAndAdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("uuid") != null && !jsonObj.get("uuid").isJsonNull()) && !jsonObj.get("uuid").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid").toString()));
}
@@ -245,9 +246,9 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
@Override
public MixedPropertiesAndAdditionalPropertiesClass read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Model200Response.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Model200Response.java
index c64699c5d35..6cf2fa641b8 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Model200Response.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Model200Response.java
@@ -160,25 +160,26 @@ public class Model200Response {
}
/**
- * 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 Model200Response
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Model200Response
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Model200Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Model200Response.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Model200Response is not found in the empty JSON string", Model200Response.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Model200Response.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Model200Response` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Model200Response` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("class") != null && !jsonObj.get("class").isJsonNull()) && !jsonObj.get("class").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("class").toString()));
}
@@ -204,9 +205,9 @@ public class Model200Response {
@Override
public Model200Response read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelApiResponse.java
index cd745ea7195..052e952c6d8 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelApiResponse.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelApiResponse.java
@@ -188,25 +188,26 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ModelApiResponse.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelApiResponse` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelApiResponse` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -235,9 +236,9 @@ public class ModelApiResponse {
@Override
public ModelApiResponse read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelFile.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelFile.java
index ad041d9d3c7..b7e2becb181 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelFile.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelFile.java
@@ -132,25 +132,26 @@ public class ModelFile {
}
/**
- * 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 ModelFile
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ModelFile
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ModelFile.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ModelFile.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelFile is not found in the empty JSON string", ModelFile.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ModelFile.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelFile` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelFile` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("sourceURI") != null && !jsonObj.get("sourceURI").isJsonNull()) && !jsonObj.get("sourceURI").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `sourceURI` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sourceURI").toString()));
}
@@ -176,9 +177,9 @@ public class ModelFile {
@Override
public ModelFile read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelList.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelList.java
index 3ba2c2dfb1e..7916cc3e58f 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelList.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelList.java
@@ -132,25 +132,26 @@ public class ModelList {
}
/**
- * 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 ModelList
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ModelList
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ModelList.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ModelList.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelList is not found in the empty JSON string", ModelList.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ModelList.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelList` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelList` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("123-list") != null && !jsonObj.get("123-list").isJsonNull()) && !jsonObj.get("123-list").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `123-list` to be a primitive type in the JSON string but got `%s`", jsonObj.get("123-list").toString()));
}
@@ -176,9 +177,9 @@ public class ModelList {
@Override
public ModelList read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelReturn.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelReturn.java
index b6ad470b979..132dcbd8cc0 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelReturn.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ModelReturn.java
@@ -132,25 +132,26 @@ public class ModelReturn {
}
/**
- * 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 ModelReturn
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ModelReturn
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ModelReturn.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ModelReturn.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelReturn is not found in the empty JSON string", ModelReturn.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ModelReturn.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelReturn` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelReturn` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@@ -173,9 +174,9 @@ public class ModelReturn {
@Override
public ModelReturn read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Name.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Name.java
index dbc582f81da..ff66cd8879e 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Name.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Name.java
@@ -209,32 +209,33 @@ public class Name {
}
/**
- * 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 Name
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Name
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Name.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Name.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Name is not found in the empty JSON string", Name.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Name.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Name` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Name` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : Name.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();
if ((jsonObj.get("property") != null && !jsonObj.get("property").isJsonNull()) && !jsonObj.get("property").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `property` to be a primitive type in the JSON string but got `%s`", jsonObj.get("property").toString()));
}
@@ -260,9 +261,9 @@ public class Name {
@Override
public Name read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/NumberOnly.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/NumberOnly.java
index 9ab12af4256..8106cf27186 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/NumberOnly.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/NumberOnly.java
@@ -133,25 +133,26 @@ public class NumberOnly {
}
/**
- * 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 NumberOnly
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to NumberOnly
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!NumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!NumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in NumberOnly is not found in the empty JSON string", NumberOnly.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!NumberOnly.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@@ -174,9 +175,9 @@ public class NumberOnly {
@Override
public NumberOnly read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 83b3c7f4694..3df944ca297 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
@@ -322,25 +322,26 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Order.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Order` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Order` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -366,9 +367,9 @@ public class Order {
@Override
public Order read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterComposite.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterComposite.java
index 571948d8d84..923989b00e3 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterComposite.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/OuterComposite.java
@@ -189,25 +189,26 @@ public class OuterComposite {
}
/**
- * 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 OuterComposite
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to OuterComposite
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!OuterComposite.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!OuterComposite.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in OuterComposite is not found in the empty JSON string", OuterComposite.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!OuterComposite.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OuterComposite` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OuterComposite` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("my_string") != null && !jsonObj.get("my_string").isJsonNull()) && !jsonObj.get("my_string").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `my_string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("my_string").toString()));
}
@@ -233,9 +234,9 @@ public class OuterComposite {
@Override
public OuterComposite read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 1cf99a5e284..079d211ecd7 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
@@ -345,35 +345,36 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Pet.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Pet` properties. JSON: %s", entry.getKey(), jsonElement.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()));
@@ -394,7 +395,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));
};
}
}
@@ -423,9 +424,9 @@ public class Pet {
@Override
public Pet read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
index d68f24e4f02..6a0f5f2a4ee 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/ReadOnlyFirst.java
@@ -159,25 +159,26 @@ public class ReadOnlyFirst {
}
/**
- * 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 ReadOnlyFirst
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ReadOnlyFirst
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ReadOnlyFirst.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ReadOnlyFirst.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ReadOnlyFirst is not found in the empty JSON string", ReadOnlyFirst.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ReadOnlyFirst.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ReadOnlyFirst` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ReadOnlyFirst` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("bar") != null && !jsonObj.get("bar").isJsonNull()) && !jsonObj.get("bar").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `bar` to be a primitive type in the JSON string but got `%s`", jsonObj.get("bar").toString()));
}
@@ -206,9 +207,9 @@ public class ReadOnlyFirst {
@Override
public ReadOnlyFirst read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/SpecialModelName.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/SpecialModelName.java
index 39085e3f776..fbd72eb8d90 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/SpecialModelName.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/SpecialModelName.java
@@ -132,25 +132,26 @@ public class SpecialModelName {
}
/**
- * 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 SpecialModelName
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to SpecialModelName
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!SpecialModelName.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!SpecialModelName.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in SpecialModelName is not found in the empty JSON string", SpecialModelName.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!SpecialModelName.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialModelName` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `SpecialModelName` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@@ -173,9 +174,9 @@ public class SpecialModelName {
@Override
public SpecialModelName read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Tag.java
index 43e5e0fab51..dd815aaeec8 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Tag.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/Tag.java
@@ -160,25 +160,26 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Tag.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Tag` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -204,9 +205,9 @@ public class Tag {
@Override
public Tag read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderDefault.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderDefault.java
index bc20cdf5b3b..8c09e9cdd3d 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderDefault.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderDefault.java
@@ -260,32 +260,33 @@ public class TypeHolderDefault {
}
/**
- * 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 TypeHolderDefault
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to TypeHolderDefault
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!TypeHolderDefault.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!TypeHolderDefault.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in TypeHolderDefault is not found in the empty JSON string", TypeHolderDefault.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!TypeHolderDefault.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderDefault` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderDefault` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : TypeHolderDefault.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();
if (!jsonObj.get("string_item").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `string_item` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_item").toString()));
}
@@ -317,9 +318,9 @@ public class TypeHolderDefault {
@Override
public TypeHolderDefault read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderExample.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderExample.java
index 931fe392e9c..09314d51c35 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderExample.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/TypeHolderExample.java
@@ -289,32 +289,33 @@ public class TypeHolderExample {
}
/**
- * 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 TypeHolderExample
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to TypeHolderExample
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!TypeHolderExample.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!TypeHolderExample.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in TypeHolderExample is not found in the empty JSON string", TypeHolderExample.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!TypeHolderExample.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderExample` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TypeHolderExample` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : TypeHolderExample.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();
if (!jsonObj.get("string_item").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `string_item` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_item").toString()));
}
@@ -346,9 +347,9 @@ public class TypeHolderExample {
@Override
public TypeHolderExample read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/User.java
index 4a518308934..ddfa460ef48 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/User.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/User.java
@@ -328,25 +328,26 @@ 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!User.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `User` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `User` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -387,9 +388,9 @@ public class User {
@Override
public User read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/XmlItem.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/XmlItem.java
index 825fd011889..51ed8c3b949 100644
--- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/XmlItem.java
+++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/XmlItem.java
@@ -991,25 +991,26 @@ public class XmlItem {
}
/**
- * 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 XmlItem
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to XmlItem
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!XmlItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!XmlItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in XmlItem is not found in the empty JSON string", XmlItem.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!XmlItem.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `XmlItem` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `XmlItem` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("attribute_string") != null && !jsonObj.get("attribute_string").isJsonNull()) && !jsonObj.get("attribute_string").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `attribute_string` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attribute_string").toString()));
}
@@ -1083,9 +1084,9 @@ public class XmlItem {
@Override
public XmlItem read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java
index 3ecdbda0716..5aef445f0cf 100644
--- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java
+++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Category.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java
index 135ecf70fc0..f4f09dbfb17 100644
--- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java
+++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/ModelApiResponse.java
@@ -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 entry : jsonObj.entrySet()) {
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 f5abae46523..004059b8f76 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
@@ -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 entry : jsonObj.entrySet()) {
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 39ba8d3643f..54d44c9c469 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
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java
index 9c1f9247b1b..97fe598e2e1 100644
--- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java
+++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/Tag.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/User.java
index 2008add2959..f7aa406f479 100644
--- a/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/User.java
+++ b/samples/client/petstore/java/okhttp-gson-group-parameter/src/main/java/org/openapitools/client/model/User.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Category.java
index 3ecdbda0716..5aef445f0cf 100644
--- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Category.java
+++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Category.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/ModelApiResponse.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/ModelApiResponse.java
index 135ecf70fc0..f4f09dbfb17 100644
--- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/ModelApiResponse.java
+++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/ModelApiResponse.java
@@ -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 entry : jsonObj.entrySet()) {
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 f5abae46523..004059b8f76 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
@@ -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 entry : jsonObj.entrySet()) {
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 39ba8d3643f..54d44c9c469 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
@@ -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 entry : jsonObj.entrySet()) {
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 165d38c65ed..d1839c9317e 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
@@ -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 entry : jsonObj.entrySet()) {
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 8bea0cee0b0..7cf21a818f9 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
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Tag.java
index 9c1f9247b1b..97fe598e2e1 100644
--- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Tag.java
+++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/Tag.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/User.java b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/User.java
index 2008add2959..f7aa406f479 100644
--- a/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/User.java
+++ b/samples/client/petstore/java/okhttp-gson-nullable-required/src/main/java/org/openapitools/client/model/User.java
@@ -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 entry : jsonObj.entrySet()) {
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md
index 98f0b0098b8..0736ffc044d 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md
@@ -251,7 +251,7 @@ public class Example {
### Return type
-[**BigDecimal**](BigDecimal.md)
+**BigDecimal**
### Authorization
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
index 2c09483bb2f..8d642af57bf 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java
@@ -155,25 +155,26 @@ public class AdditionalPropertiesAnyType implements Parcelable {
}
/**
- * 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 AdditionalPropertiesAnyType
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesAnyType
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesAnyType.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesAnyType.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesAnyType.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -199,9 +200,9 @@ public class AdditionalPropertiesAnyType implements Parcelable {
@Override
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
index b2e9ab096a4..fe46853e434 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java
@@ -156,25 +156,26 @@ public class AdditionalPropertiesArray implements Parcelable {
}
/**
- * 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 AdditionalPropertiesArray
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesArray
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesArray.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesArray.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesArray.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -200,9 +201,9 @@ public class AdditionalPropertiesArray implements Parcelable {
@Override
public AdditionalPropertiesArray read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
index f01c877c557..aa666774ec5 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java
@@ -155,25 +155,26 @@ public class AdditionalPropertiesBoolean implements Parcelable {
}
/**
- * 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 AdditionalPropertiesBoolean
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesBoolean
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesBoolean.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesBoolean.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesBoolean.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -199,9 +200,9 @@ public class AdditionalPropertiesBoolean implements Parcelable {
@Override
public AdditionalPropertiesBoolean read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
index d35eaeca5dc..eda493d4032 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesClass.java
@@ -475,7 +475,7 @@ public class AdditionalPropertiesClass implements Parcelable {
AdditionalPropertiesClass(Parcel in) {
mapString = (Map)in.readValue(null);
- mapNumber = (Map)in.readValue(BigDecimal.class.getClassLoader());
+ mapNumber = (Map)in.readValue(null);
mapInteger = (Map)in.readValue(null);
mapBoolean = (Map)in.readValue(null);
mapArrayInteger = (Map>)in.readValue(List.class.getClassLoader());
@@ -523,25 +523,26 @@ public class AdditionalPropertiesClass implements Parcelable {
}
/**
- * 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 AdditionalPropertiesClass
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesClass
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesClass.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesClass is not found in the empty JSON string", AdditionalPropertiesClass.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesClass.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@@ -564,9 +565,9 @@ public class AdditionalPropertiesClass implements Parcelable {
@Override
public AdditionalPropertiesClass read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java
index f70996848af..590b21a6a18 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java
@@ -155,25 +155,26 @@ public class AdditionalPropertiesInteger implements Parcelable {
}
/**
- * 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 AdditionalPropertiesInteger
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesInteger
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesInteger.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesInteger.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesInteger.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -199,9 +200,9 @@ public class AdditionalPropertiesInteger implements Parcelable {
@Override
public AdditionalPropertiesInteger read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java
index 505f67c4c1d..95c0c465ad8 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java
@@ -156,25 +156,26 @@ public class AdditionalPropertiesNumber implements Parcelable {
}
/**
- * 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 AdditionalPropertiesNumber
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesNumber
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesNumber.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesNumber.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesNumber.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -200,9 +201,9 @@ public class AdditionalPropertiesNumber implements Parcelable {
@Override
public AdditionalPropertiesNumber read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java
index 0a334eb4450..d6179b5e062 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java
@@ -156,25 +156,26 @@ public class AdditionalPropertiesObject implements Parcelable {
}
/**
- * 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 AdditionalPropertiesObject
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesObject
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesObject.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -200,9 +201,9 @@ public class AdditionalPropertiesObject implements Parcelable {
@Override
public AdditionalPropertiesObject read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java
index 3bb42ab64c4..a01f05e1b2b 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java
@@ -155,25 +155,26 @@ public class AdditionalPropertiesString implements Parcelable {
}
/**
- * 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 AdditionalPropertiesString
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to AdditionalPropertiesString
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!AdditionalPropertiesString.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!AdditionalPropertiesString.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!AdditionalPropertiesString.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonElement.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()));
}
@@ -199,9 +200,9 @@ public class AdditionalPropertiesString implements Parcelable {
@Override
public AdditionalPropertiesString read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Animal.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Animal.java
index 10adfe83252..3ad111c16dd 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Animal.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Animal.java
@@ -187,28 +187,28 @@ public class Animal implements Parcelable {
}
/**
- * 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 Animal
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Animal
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Animal.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Animal.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Animal is not found in the empty JSON string", Animal.openapiRequiredFields.toString()));
}
}
- String discriminatorValue = jsonObj.get("className").getAsString();
+ String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString();
switch (discriminatorValue) {
case "BigCat":
- BigCat.validateJsonObject(jsonObj);
+ BigCat.validateJsonElement(jsonElement);
break;
case "Cat":
- Cat.validateJsonObject(jsonObj);
+ Cat.validateJsonElement(jsonElement);
break;
case "Dog":
- Dog.validateJsonObject(jsonObj);
+ Dog.validateJsonElement(jsonElement);
break;
default:
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
index 2de2ddb34b1..9568e053415 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnly.java
@@ -166,25 +166,26 @@ public class ArrayOfArrayOfNumberOnly implements Parcelable {
}
/**
- * 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 ArrayOfArrayOfNumberOnly
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ArrayOfArrayOfNumberOnly
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ArrayOfArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfArrayOfNumberOnly is not found in the empty JSON string", ArrayOfArrayOfNumberOnly.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ArrayOfArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("ArrayArrayNumber") != null && !jsonObj.get("ArrayArrayNumber").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `ArrayArrayNumber` to be an array in the JSON string but got `%s`", jsonObj.get("ArrayArrayNumber").toString()));
@@ -211,9 +212,9 @@ public class ArrayOfArrayOfNumberOnly implements Parcelable {
@Override
public ArrayOfArrayOfNumberOnly read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
index a1c42d7fdf2..455f0446f31 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayOfNumberOnly.java
@@ -137,7 +137,7 @@ public class ArrayOfNumberOnly implements Parcelable {
}
ArrayOfNumberOnly(Parcel in) {
- arrayNumber = (List)in.readValue(BigDecimal.class.getClassLoader());
+ arrayNumber = (List)in.readValue(null);
}
public int describeContents() {
@@ -166,25 +166,26 @@ public class ArrayOfNumberOnly implements Parcelable {
}
/**
- * 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 ArrayOfNumberOnly
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ArrayOfNumberOnly
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ArrayOfNumberOnly.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayOfNumberOnly is not found in the empty JSON string", ArrayOfNumberOnly.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ArrayOfNumberOnly.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayOfNumberOnly` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("ArrayNumber") != null && !jsonObj.get("ArrayNumber").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `ArrayNumber` to be an array in the JSON string but got `%s`", jsonObj.get("ArrayNumber").toString()));
@@ -211,9 +212,9 @@ public class ArrayOfNumberOnly implements Parcelable {
@Override
public ArrayOfNumberOnly read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayTest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayTest.java
index 5319e4fef22..2a3bd88782f 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayTest.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ArrayTest.java
@@ -242,25 +242,26 @@ public class ArrayTest implements Parcelable {
}
/**
- * 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 ArrayTest
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ArrayTest
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ArrayTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ArrayTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ArrayTest is not found in the empty JSON string", ArrayTest.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ArrayTest.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ArrayTest` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
// ensure the optional json data is an array if present
if (jsonObj.get("array_of_string") != null && !jsonObj.get("array_of_string").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `array_of_string` to be an array in the JSON string but got `%s`", jsonObj.get("array_of_string").toString()));
@@ -295,9 +296,9 @@ public class ArrayTest implements Parcelable {
@Override
public ArrayTest read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 ff134797efd..f481969ee2b 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
@@ -217,30 +217,30 @@ public class BigCat extends Cat implements Parcelable {
}
/**
- * 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 BigCat
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to BigCat
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!BigCat.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!BigCat.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in BigCat is not found in the empty JSON string", BigCat.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!BigCat.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCat` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `BigCat` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : BigCat.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()));
}
}
}
@@ -265,9 +265,9 @@ public class BigCat extends Cat implements Parcelable {
@Override
public BigCat read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Capitalization.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Capitalization.java
index b845a0916b9..c0950b22581 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Capitalization.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Capitalization.java
@@ -305,25 +305,26 @@ public class Capitalization implements Parcelable {
}
/**
- * 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 Capitalization
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Capitalization
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Capitalization.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Capitalization.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Capitalization is not found in the empty JSON string", Capitalization.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Capitalization.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Capitalization` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("smallCamel") != null && !jsonObj.get("smallCamel").isJsonNull()) && !jsonObj.get("smallCamel").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `smallCamel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("smallCamel").toString()));
}
@@ -364,9 +365,9 @@ public class Capitalization implements Parcelable {
@Override
public Capitalization read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Cat.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Cat.java
index 0bba8095754..4e19977b34a 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Cat.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Cat.java
@@ -165,22 +165,22 @@ public class Cat extends Animal implements Parcelable {
}
/**
- * 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 Cat
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Cat
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Cat.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Cat.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Cat is not found in the empty JSON string", Cat.openapiRequiredFields.toString()));
}
}
- String discriminatorValue = jsonObj.get("className").getAsString();
+ String discriminatorValue = jsonElement.getAsJsonObject().get("className").getAsString();
switch (discriminatorValue) {
case "BigCat":
- BigCat.validateJsonObject(jsonObj);
+ BigCat.validateJsonElement(jsonElement);
break;
default:
throw new IllegalArgumentException(String.format("The value of the `className` field `%s` does not match any key defined in the discriminator's mapping.", discriminatorValue));
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Category.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Category.java
index 676aac4b71e..6d66825be4c 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Category.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Category.java
@@ -186,32 +186,33 @@ public class Category implements Parcelable {
}
/**
- * 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()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Category.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Category` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : Category.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();
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()));
}
@@ -237,9 +238,9 @@ public class Category implements Parcelable {
@Override
public Category read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ClassModel.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ClassModel.java
index bc369c13720..6be5c6349c8 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ClassModel.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/ClassModel.java
@@ -155,25 +155,26 @@ public class ClassModel implements Parcelable {
}
/**
- * 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 ClassModel
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to ClassModel
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!ClassModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!ClassModel.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ClassModel is not found in the empty JSON string", ClassModel.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ClassModel.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ClassModel` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("_class") != null && !jsonObj.get("_class").isJsonNull()) && !jsonObj.get("_class").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `_class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("_class").toString()));
}
@@ -199,9 +200,9 @@ public class ClassModel implements Parcelable {
@Override
public ClassModel read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Client.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Client.java
index 4969cd52e8c..6f91506b1f1 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Client.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Client.java
@@ -155,25 +155,26 @@ public class Client implements Parcelable {
}
/**
- * 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 Client
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Client
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Client.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Client.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Client is not found in the empty JSON string", Client.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Client.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Client` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("client") != null && !jsonObj.get("client").isJsonNull()) && !jsonObj.get("client").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `client` to be a primitive type in the JSON string but got `%s`", jsonObj.get("client").toString()));
}
@@ -199,9 +200,9 @@ public class Client implements Parcelable {
@Override
public Client read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Dog.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Dog.java
index fbdece54bd1..93b741aa111 100644
--- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Dog.java
+++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/Dog.java
@@ -165,30 +165,30 @@ public class Dog extends Animal implements Parcelable {
}
/**
- * 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 Dog
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to Dog
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!Dog.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!Dog.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in Dog is not found in the empty JSON string", Dog.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!Dog.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Dog` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : Dog.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()));
}
}
}
@@ -213,9 +213,9 @@ public class Dog extends Animal implements Parcelable {
@Override
public Dog read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 0eb7faa4530..a8761834d36 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
@@ -289,25 +289,26 @@ public class EnumArrays implements Parcelable {
}
/**
- * 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 EnumArrays
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to EnumArrays
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!EnumArrays.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!EnumArrays.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumArrays is not found in the empty JSON string", EnumArrays.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!EnumArrays.openapiFields.contains(entry.getKey())) {
- throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
+ throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `EnumArrays` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
+ JsonObject jsonObj = jsonElement.getAsJsonObject();
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()));
}
@@ -337,9 +338,9 @@ public class EnumArrays implements Parcelable {
@Override
public EnumArrays read(JsonReader in) throws IOException {
- JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
- validateJsonObject(jsonObj);
- return thisAdapter.fromJsonTree(jsonObj);
+ JsonElement jsonElement = elementAdapter.read(in);
+ validateJsonElement(jsonElement);
+ return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
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 32547e0ed23..34dae2aca48 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
@@ -469,32 +469,33 @@ public class EnumTest implements Parcelable {
}
/**
- * 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 EnumTest
+ * @param jsonElement JSON Element
+ * @throws IOException if the JSON Element is invalid with respect to EnumTest
*/
- public static void validateJsonObject(JsonObject jsonObj) throws IOException {
- if (jsonObj == null) {
- if (!EnumTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
+ public static void validateJsonElement(JsonElement jsonElement) throws IOException {
+ if (jsonElement == null) {
+ if (!EnumTest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in EnumTest is not found in the empty JSON string", EnumTest.openapiRequiredFields.toString()));
}
}
- Set> entries = jsonObj.entrySet();
+ Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry