forked from loafle/openapi-generator-original
[Default] update isAdditionalPropertiesTrue tag to cover more types (#16227)
* enhance additional properties support * update samples * update tests * add more tests * update samples * fix samples
This commit is contained in:
@@ -79,6 +79,50 @@ public class AdditionalPropertiesAnyType {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesAnyType instance itself
|
||||
*/
|
||||
public AdditionalPropertiesAnyType putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -90,12 +134,13 @@ public class AdditionalPropertiesAnyType {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o;
|
||||
return Objects.equals(this.name, additionalPropertiesAnyType.name);
|
||||
return Objects.equals(this.name, additionalPropertiesAnyType.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesAnyType.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,6 +148,7 @@ public class AdditionalPropertiesAnyType {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesAnyType {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -143,14 +189,6 @@ public class AdditionalPropertiesAnyType {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -172,6 +210,23 @@ public class AdditionalPropertiesAnyType {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -179,7 +234,28 @@ public class AdditionalPropertiesAnyType {
|
||||
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesAnyType instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -80,6 +80,50 @@ public class AdditionalPropertiesArray {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesArray instance itself
|
||||
*/
|
||||
public AdditionalPropertiesArray putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -91,12 +135,13 @@ public class AdditionalPropertiesArray {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o;
|
||||
return Objects.equals(this.name, additionalPropertiesArray.name);
|
||||
return Objects.equals(this.name, additionalPropertiesArray.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesArray.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +149,7 @@ public class AdditionalPropertiesArray {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesArray {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -144,14 +190,6 @@ public class AdditionalPropertiesArray {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -173,6 +211,23 @@ public class AdditionalPropertiesArray {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesArray value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -180,7 +235,28 @@ public class AdditionalPropertiesArray {
|
||||
public AdditionalPropertiesArray read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesArray instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -79,6 +79,50 @@ public class AdditionalPropertiesBoolean {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesBoolean instance itself
|
||||
*/
|
||||
public AdditionalPropertiesBoolean putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -90,12 +134,13 @@ public class AdditionalPropertiesBoolean {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o;
|
||||
return Objects.equals(this.name, additionalPropertiesBoolean.name);
|
||||
return Objects.equals(this.name, additionalPropertiesBoolean.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesBoolean.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,6 +148,7 @@ public class AdditionalPropertiesBoolean {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesBoolean {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -143,14 +189,6 @@ public class AdditionalPropertiesBoolean {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -172,6 +210,23 @@ public class AdditionalPropertiesBoolean {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesBoolean value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -179,7 +234,28 @@ public class AdditionalPropertiesBoolean {
|
||||
public AdditionalPropertiesBoolean read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesBoolean instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -79,6 +79,50 @@ public class AdditionalPropertiesInteger {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesInteger instance itself
|
||||
*/
|
||||
public AdditionalPropertiesInteger putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -90,12 +134,13 @@ public class AdditionalPropertiesInteger {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o;
|
||||
return Objects.equals(this.name, additionalPropertiesInteger.name);
|
||||
return Objects.equals(this.name, additionalPropertiesInteger.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesInteger.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,6 +148,7 @@ public class AdditionalPropertiesInteger {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesInteger {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -143,14 +189,6 @@ public class AdditionalPropertiesInteger {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -172,6 +210,23 @@ public class AdditionalPropertiesInteger {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesInteger value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -179,7 +234,28 @@ public class AdditionalPropertiesInteger {
|
||||
public AdditionalPropertiesInteger read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesInteger instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -80,6 +80,50 @@ public class AdditionalPropertiesNumber {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesNumber instance itself
|
||||
*/
|
||||
public AdditionalPropertiesNumber putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -91,12 +135,13 @@ public class AdditionalPropertiesNumber {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o;
|
||||
return Objects.equals(this.name, additionalPropertiesNumber.name);
|
||||
return Objects.equals(this.name, additionalPropertiesNumber.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesNumber.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +149,7 @@ public class AdditionalPropertiesNumber {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesNumber {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -144,14 +190,6 @@ public class AdditionalPropertiesNumber {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -173,6 +211,23 @@ public class AdditionalPropertiesNumber {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesNumber value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -180,7 +235,28 @@ public class AdditionalPropertiesNumber {
|
||||
public AdditionalPropertiesNumber read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesNumber instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -80,6 +80,50 @@ public class AdditionalPropertiesObject {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesObject instance itself
|
||||
*/
|
||||
public AdditionalPropertiesObject putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -91,12 +135,13 @@ public class AdditionalPropertiesObject {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o;
|
||||
return Objects.equals(this.name, additionalPropertiesObject.name);
|
||||
return Objects.equals(this.name, additionalPropertiesObject.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesObject.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +149,7 @@ public class AdditionalPropertiesObject {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesObject {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -144,14 +190,6 @@ public class AdditionalPropertiesObject {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -173,6 +211,23 @@ public class AdditionalPropertiesObject {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -180,7 +235,28 @@ public class AdditionalPropertiesObject {
|
||||
public AdditionalPropertiesObject read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesObject instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -79,6 +79,50 @@ public class AdditionalPropertiesString {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesString instance itself
|
||||
*/
|
||||
public AdditionalPropertiesString putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -90,12 +134,13 @@ public class AdditionalPropertiesString {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o;
|
||||
return Objects.equals(this.name, additionalPropertiesString.name);
|
||||
return Objects.equals(this.name, additionalPropertiesString.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesString.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,6 +148,7 @@ public class AdditionalPropertiesString {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesString {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -143,14 +189,6 @@ public class AdditionalPropertiesString {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -172,6 +210,23 @@ public class AdditionalPropertiesString {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesString value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -179,7 +234,28 @@ public class AdditionalPropertiesString {
|
||||
public AdditionalPropertiesString read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesString instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -81,6 +81,50 @@ public class AdditionalPropertiesAnyType implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesAnyType instance itself
|
||||
*/
|
||||
public AdditionalPropertiesAnyType putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -92,12 +136,13 @@ public class AdditionalPropertiesAnyType implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o;
|
||||
return Objects.equals(this.name, additionalPropertiesAnyType.name);
|
||||
return Objects.equals(this.name, additionalPropertiesAnyType.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesAnyType.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,6 +150,7 @@ public class AdditionalPropertiesAnyType implements Parcelable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesAnyType {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -166,14 +212,6 @@ public class AdditionalPropertiesAnyType implements Parcelable {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -195,6 +233,23 @@ public class AdditionalPropertiesAnyType implements Parcelable {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -202,7 +257,28 @@ public class AdditionalPropertiesAnyType implements Parcelable {
|
||||
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesAnyType instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -82,6 +82,50 @@ public class AdditionalPropertiesArray implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesArray instance itself
|
||||
*/
|
||||
public AdditionalPropertiesArray putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -93,12 +137,13 @@ public class AdditionalPropertiesArray implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o;
|
||||
return Objects.equals(this.name, additionalPropertiesArray.name);
|
||||
return Objects.equals(this.name, additionalPropertiesArray.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesArray.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,6 +151,7 @@ public class AdditionalPropertiesArray implements Parcelable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesArray {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -167,14 +213,6 @@ public class AdditionalPropertiesArray implements Parcelable {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -196,6 +234,23 @@ public class AdditionalPropertiesArray implements Parcelable {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesArray value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -203,7 +258,28 @@ public class AdditionalPropertiesArray implements Parcelable {
|
||||
public AdditionalPropertiesArray read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesArray instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -81,6 +81,50 @@ public class AdditionalPropertiesBoolean implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesBoolean instance itself
|
||||
*/
|
||||
public AdditionalPropertiesBoolean putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -92,12 +136,13 @@ public class AdditionalPropertiesBoolean implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o;
|
||||
return Objects.equals(this.name, additionalPropertiesBoolean.name);
|
||||
return Objects.equals(this.name, additionalPropertiesBoolean.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesBoolean.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,6 +150,7 @@ public class AdditionalPropertiesBoolean implements Parcelable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesBoolean {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -166,14 +212,6 @@ public class AdditionalPropertiesBoolean implements Parcelable {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -195,6 +233,23 @@ public class AdditionalPropertiesBoolean implements Parcelable {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesBoolean value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -202,7 +257,28 @@ public class AdditionalPropertiesBoolean implements Parcelable {
|
||||
public AdditionalPropertiesBoolean read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesBoolean instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -81,6 +81,50 @@ public class AdditionalPropertiesInteger implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesInteger instance itself
|
||||
*/
|
||||
public AdditionalPropertiesInteger putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -92,12 +136,13 @@ public class AdditionalPropertiesInteger implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o;
|
||||
return Objects.equals(this.name, additionalPropertiesInteger.name);
|
||||
return Objects.equals(this.name, additionalPropertiesInteger.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesInteger.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,6 +150,7 @@ public class AdditionalPropertiesInteger implements Parcelable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesInteger {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -166,14 +212,6 @@ public class AdditionalPropertiesInteger implements Parcelable {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -195,6 +233,23 @@ public class AdditionalPropertiesInteger implements Parcelable {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesInteger value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -202,7 +257,28 @@ public class AdditionalPropertiesInteger implements Parcelable {
|
||||
public AdditionalPropertiesInteger read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesInteger instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -82,6 +82,50 @@ public class AdditionalPropertiesNumber implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesNumber instance itself
|
||||
*/
|
||||
public AdditionalPropertiesNumber putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -93,12 +137,13 @@ public class AdditionalPropertiesNumber implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o;
|
||||
return Objects.equals(this.name, additionalPropertiesNumber.name);
|
||||
return Objects.equals(this.name, additionalPropertiesNumber.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesNumber.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,6 +151,7 @@ public class AdditionalPropertiesNumber implements Parcelable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesNumber {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -167,14 +213,6 @@ public class AdditionalPropertiesNumber implements Parcelable {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -196,6 +234,23 @@ public class AdditionalPropertiesNumber implements Parcelable {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesNumber value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -203,7 +258,28 @@ public class AdditionalPropertiesNumber implements Parcelable {
|
||||
public AdditionalPropertiesNumber read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesNumber instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -82,6 +82,50 @@ public class AdditionalPropertiesObject implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesObject instance itself
|
||||
*/
|
||||
public AdditionalPropertiesObject putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -93,12 +137,13 @@ public class AdditionalPropertiesObject implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o;
|
||||
return Objects.equals(this.name, additionalPropertiesObject.name);
|
||||
return Objects.equals(this.name, additionalPropertiesObject.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesObject.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,6 +151,7 @@ public class AdditionalPropertiesObject implements Parcelable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesObject {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -167,14 +213,6 @@ public class AdditionalPropertiesObject implements Parcelable {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -196,6 +234,23 @@ public class AdditionalPropertiesObject implements Parcelable {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -203,7 +258,28 @@ public class AdditionalPropertiesObject implements Parcelable {
|
||||
public AdditionalPropertiesObject read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesObject instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -81,6 +81,50 @@ public class AdditionalPropertiesString implements Parcelable {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the AdditionalPropertiesString instance itself
|
||||
*/
|
||||
public AdditionalPropertiesString putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -92,12 +136,13 @@ public class AdditionalPropertiesString implements Parcelable {
|
||||
return false;
|
||||
}
|
||||
AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o;
|
||||
return Objects.equals(this.name, additionalPropertiesString.name);
|
||||
return Objects.equals(this.name, additionalPropertiesString.name)&&
|
||||
Objects.equals(this.additionalProperties, additionalPropertiesString.additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
return Objects.hash(name, additionalProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,6 +150,7 @@ public class AdditionalPropertiesString implements Parcelable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class AdditionalPropertiesString {\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -166,14 +212,6 @@ public class AdditionalPropertiesString implements Parcelable {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> 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(), 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()));
|
||||
@@ -195,6 +233,23 @@ public class AdditionalPropertiesString implements Parcelable {
|
||||
@Override
|
||||
public void write(JsonWriter out, AdditionalPropertiesString value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -202,7 +257,28 @@ public class AdditionalPropertiesString implements Parcelable {
|
||||
public AdditionalPropertiesString read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
AdditionalPropertiesString instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -169,6 +169,50 @@ public class Drawing {
|
||||
this.shapes = shapes;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the Drawing instance itself
|
||||
*/
|
||||
public Drawing putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -183,7 +227,8 @@ public class Drawing {
|
||||
return Objects.equals(this.mainShape, drawing.mainShape) &&
|
||||
Objects.equals(this.shapeOrNull, drawing.shapeOrNull) &&
|
||||
Objects.equals(this.nullableShape, drawing.nullableShape) &&
|
||||
Objects.equals(this.shapes, drawing.shapes);
|
||||
Objects.equals(this.shapes, drawing.shapes)&&
|
||||
Objects.equals(this.additionalProperties, drawing.additionalProperties);
|
||||
}
|
||||
|
||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||
@@ -192,7 +237,7 @@ public class Drawing {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mainShape, shapeOrNull, nullableShape, shapes);
|
||||
return Objects.hash(mainShape, shapeOrNull, nullableShape, shapes, additionalProperties);
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
@@ -210,6 +255,7 @@ public class Drawing {
|
||||
sb.append(" shapeOrNull: ").append(toIndentedString(shapeOrNull)).append("\n");
|
||||
sb.append(" nullableShape: ").append(toIndentedString(nullableShape)).append("\n");
|
||||
sb.append(" shapes: ").append(toIndentedString(shapes)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -253,14 +299,6 @@ public class Drawing {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in Drawing is not found in the empty JSON string", Drawing.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!Drawing.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Drawing` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// validate the optional field `mainShape`
|
||||
if (jsonObj.get("mainShape") != null && !jsonObj.get("mainShape").isJsonNull()) {
|
||||
@@ -305,6 +343,23 @@ public class Drawing {
|
||||
@Override
|
||||
public void write(JsonWriter out, Drawing value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -312,7 +367,28 @@ public class Drawing {
|
||||
public Drawing read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
Drawing instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
@@ -410,6 +410,50 @@ public class NullableClass {
|
||||
this.objectItemsNullable = objectItemsNullable;
|
||||
}
|
||||
|
||||
/**
|
||||
* A container for additional, undeclared properties.
|
||||
* This is a holder for any undeclared properties as specified with
|
||||
* the 'additionalProperties' keyword in the OAS document.
|
||||
*/
|
||||
private Map<String, Object> additionalProperties;
|
||||
|
||||
/**
|
||||
* Set the additional (undeclared) property with the specified name and value.
|
||||
* If the property does not already exist, create it otherwise replace it.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @param value value of the property
|
||||
* @return the NullableClass instance itself
|
||||
*/
|
||||
public NullableClass putAdditionalProperty(String key, Object value) {
|
||||
if (this.additionalProperties == null) {
|
||||
this.additionalProperties = new HashMap<String, Object>();
|
||||
}
|
||||
this.additionalProperties.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property.
|
||||
*
|
||||
* @return a map of objects
|
||||
*/
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return additionalProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the additional (undeclared) property with the specified name.
|
||||
*
|
||||
* @param key name of the property
|
||||
* @return an object
|
||||
*/
|
||||
public Object getAdditionalProperty(String key) {
|
||||
if (this.additionalProperties == null) {
|
||||
return null;
|
||||
}
|
||||
return this.additionalProperties.get(key);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@@ -432,7 +476,8 @@ public class NullableClass {
|
||||
Objects.equals(this.arrayItemsNullable, nullableClass.arrayItemsNullable) &&
|
||||
Objects.equals(this.objectNullableProp, nullableClass.objectNullableProp) &&
|
||||
Objects.equals(this.objectAndItemsNullableProp, nullableClass.objectAndItemsNullableProp) &&
|
||||
Objects.equals(this.objectItemsNullable, nullableClass.objectItemsNullable);
|
||||
Objects.equals(this.objectItemsNullable, nullableClass.objectItemsNullable)&&
|
||||
Objects.equals(this.additionalProperties, nullableClass.additionalProperties);
|
||||
}
|
||||
|
||||
private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
|
||||
@@ -441,7 +486,7 @@ public class NullableClass {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(integerProp, numberProp, booleanProp, stringProp, dateProp, datetimeProp, arrayNullableProp, arrayAndItemsNullableProp, arrayItemsNullable, objectNullableProp, objectAndItemsNullableProp, objectItemsNullable);
|
||||
return Objects.hash(integerProp, numberProp, booleanProp, stringProp, dateProp, datetimeProp, arrayNullableProp, arrayAndItemsNullableProp, arrayItemsNullable, objectNullableProp, objectAndItemsNullableProp, objectItemsNullable, additionalProperties);
|
||||
}
|
||||
|
||||
private static <T> int hashCodeNullable(JsonNullable<T> a) {
|
||||
@@ -467,6 +512,7 @@ public class NullableClass {
|
||||
sb.append(" objectNullableProp: ").append(toIndentedString(objectNullableProp)).append("\n");
|
||||
sb.append(" objectAndItemsNullableProp: ").append(toIndentedString(objectAndItemsNullableProp)).append("\n");
|
||||
sb.append(" objectItemsNullable: ").append(toIndentedString(objectItemsNullable)).append("\n");
|
||||
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -518,14 +564,6 @@ public class NullableClass {
|
||||
throw new IllegalArgumentException(String.format("The required field(s) %s in NullableClass is not found in the empty JSON string", NullableClass.openapiRequiredFields.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
|
||||
// check to see if the JSON string contains additional fields
|
||||
for (Entry<String, JsonElement> entry : entries) {
|
||||
if (!NullableClass.openapiFields.contains(entry.getKey())) {
|
||||
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NullableClass` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
||||
}
|
||||
}
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
if ((jsonObj.get("string_prop") != null && !jsonObj.get("string_prop").isJsonNull()) && !jsonObj.get("string_prop").isJsonPrimitive()) {
|
||||
throw new IllegalArgumentException(String.format("Expected the field `string_prop` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_prop").toString()));
|
||||
@@ -559,6 +597,23 @@ public class NullableClass {
|
||||
@Override
|
||||
public void write(JsonWriter out, NullableClass value) throws IOException {
|
||||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
||||
obj.remove("additionalProperties");
|
||||
// serialize additional properties
|
||||
if (value.getAdditionalProperties() != null) {
|
||||
for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
|
||||
if (entry.getValue() instanceof String)
|
||||
obj.addProperty(entry.getKey(), (String) entry.getValue());
|
||||
else if (entry.getValue() instanceof Number)
|
||||
obj.addProperty(entry.getKey(), (Number) entry.getValue());
|
||||
else if (entry.getValue() instanceof Boolean)
|
||||
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
|
||||
else if (entry.getValue() instanceof Character)
|
||||
obj.addProperty(entry.getKey(), (Character) entry.getValue());
|
||||
else {
|
||||
obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementAdapter.write(out, obj);
|
||||
}
|
||||
|
||||
@@ -566,7 +621,28 @@ public class NullableClass {
|
||||
public NullableClass read(JsonReader in) throws IOException {
|
||||
JsonElement jsonElement = elementAdapter.read(in);
|
||||
validateJsonElement(jsonElement);
|
||||
return thisAdapter.fromJsonTree(jsonElement);
|
||||
JsonObject jsonObj = jsonElement.getAsJsonObject();
|
||||
// store additional fields in the deserialized instance
|
||||
NullableClass instance = thisAdapter.fromJsonTree(jsonObj);
|
||||
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
|
||||
if (!openapiFields.contains(entry.getKey())) {
|
||||
if (entry.getValue().isJsonPrimitive()) { // primitive type
|
||||
if (entry.getValue().getAsJsonPrimitive().isString())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isNumber())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
|
||||
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
|
||||
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
|
||||
else
|
||||
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
|
||||
} else if (entry.getValue().isJsonArray()) {
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
|
||||
} else { // JSON object
|
||||
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
}.nullSafe();
|
||||
|
||||
Reference in New Issue
Block a user