Compare commits

...

3 Commits

Author SHA1 Message Date
William Cheng
8ecf9e352d fix additional properties any type 2023-07-30 16:25:18 +08:00
William Cheng
07d4f7d534 update template and samples 2023-07-30 16:20:45 +08:00
William Cheng
659885f509 better additional properties support 2023-07-30 16:15:07 +08:00
61 changed files with 1676 additions and 165 deletions

View File

@ -153,6 +153,23 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
*/ */
public boolean isAdditionalPropertiesTrue; public boolean isAdditionalPropertiesTrue;
/**
* True if additional properties is set to any type
*/
public boolean isAdditionalPropertiesAnyType;
/**
* True if additional properties is set to free form object
*/
public boolean isAdditionalPropertiesFreeFormObject;
/**
* True if additional properties is enabled (boolean or any type)
*/
public boolean isAdditionalPropertiesEnabled() {
return isAdditionalPropertiesTrue || isAdditionalPropertiesAnyType || isAdditionalPropertiesFreeFormObject;
}
private Integer maxProperties; private Integer maxProperties;
private Integer minProperties; private Integer minProperties;
private boolean uniqueItems; private boolean uniqueItems;
@ -1088,6 +1105,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
Objects.equals(externalDocumentation, that.externalDocumentation) && Objects.equals(externalDocumentation, that.externalDocumentation) &&
Objects.equals(vendorExtensions, that.vendorExtensions) && Objects.equals(vendorExtensions, that.vendorExtensions) &&
Objects.equals(additionalPropertiesType, that.additionalPropertiesType) && Objects.equals(additionalPropertiesType, that.additionalPropertiesType) &&
Objects.equals(isAdditionalPropertiesAnyType, that.isAdditionalPropertiesAnyType) &&
Objects.equals(isAdditionalPropertiesFreeFormObject, that.isAdditionalPropertiesFreeFormObject) &&
Objects.equals(isAdditionalPropertiesTrue, that.isAdditionalPropertiesTrue) &&
Objects.equals(getMaxProperties(), that.getMaxProperties()) && Objects.equals(getMaxProperties(), that.getMaxProperties()) &&
Objects.equals(getMinProperties(), that.getMinProperties()) && Objects.equals(getMinProperties(), that.getMinProperties()) &&
Objects.equals(getMaxItems(), that.getMaxItems()) && Objects.equals(getMaxItems(), that.getMaxItems()) &&
@ -1121,7 +1141,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping, getAdditionalPropertiesIsAnyType(), hasDiscriminatorWithNonEmptyMapping,
isAnyType, getComposedSchemas(), hasMultipleTypes, isDecimal, isUuid, requiredVarsMap, ref, isAnyType, getComposedSchemas(), hasMultipleTypes, isDecimal, isUuid, requiredVarsMap, ref,
uniqueItemsBoolean, schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse, uniqueItemsBoolean, schemaIsFromAdditionalProperties, isBooleanSchemaTrue, isBooleanSchemaFalse,
format, dependentRequired, contains); format, dependentRequired, contains, isAdditionalPropertiesTrue, isAdditionalPropertiesFreeFormObject,
isAdditionalPropertiesFreeFormObject);
} }
@Override @Override
@ -1227,6 +1248,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
sb.append(", format=").append(format); sb.append(", format=").append(format);
sb.append(", dependentRequired=").append(dependentRequired); sb.append(", dependentRequired=").append(dependentRequired);
sb.append(", contains=").append(contains); sb.append(", contains=").append(contains);
sb.append(", isAdditionalPropertiesAnyType=").append(isAdditionalPropertiesAnyType);
sb.append(", isAdditionalPropertiesFreeFormObject=").append(isAdditionalPropertiesFreeFormObject);
sb.append(", isAdditionalPropertiesTrue=").append(isAdditionalPropertiesTrue);
sb.append('}'); sb.append('}');
return sb.toString(); return sb.toString();
} }

View File

@ -3167,13 +3167,16 @@ public class DefaultCodegen implements CodegenConfig {
// if we are trying to set additionalProperties on an empty schema stop recursing // if we are trying to set additionalProperties on an empty schema stop recursing
return; return;
} }
boolean additionalPropertiesIsAnyType = false; boolean additionalPropertiesIsAnyType = false;
boolean isAdditionalPropertiesTrue = false;
boolean isAdditionalPropertiesFreeFormObject = false;
CodegenModel m = null; CodegenModel m = null;
if (property instanceof CodegenModel) { if (property instanceof CodegenModel) {
m = (CodegenModel) property; m = (CodegenModel) property;
} }
CodegenProperty addPropProp = null; CodegenProperty addPropProp = null;
boolean isAdditionalPropertiesTrue = false;
if (schema.getAdditionalProperties() == null) { if (schema.getAdditionalProperties() == null) {
if (!disallowAdditionalPropertiesIfNotPresent) { if (!disallowAdditionalPropertiesIfNotPresent) {
isAdditionalPropertiesTrue = true; isAdditionalPropertiesTrue = true;
@ -3183,20 +3186,25 @@ public class DefaultCodegen implements CodegenConfig {
} else if (schema.getAdditionalProperties() instanceof Boolean) { } else if (schema.getAdditionalProperties() instanceof Boolean) {
if (Boolean.TRUE.equals(schema.getAdditionalProperties())) { if (Boolean.TRUE.equals(schema.getAdditionalProperties())) {
isAdditionalPropertiesTrue = true; isAdditionalPropertiesTrue = true;
addPropProp = fromProperty(getAdditionalPropertiesName(), new Schema(), false);
additionalPropertiesIsAnyType = true;
} }
} else { } else {
addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false); addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false);
if (ModelUtils.isAnyType((Schema) schema.getAdditionalProperties())) { if (ModelUtils.isAnyType((Schema) schema.getAdditionalProperties())) {
isAdditionalPropertiesTrue = true;
additionalPropertiesIsAnyType = true; additionalPropertiesIsAnyType = true;
} }
if (ModelUtils.isFreeFormObject((Schema) schema.getAdditionalProperties())) {
isAdditionalPropertiesFreeFormObject = true;
}
} }
if (additionalPropertiesIsAnyType) { if (additionalPropertiesIsAnyType) {
property.setAdditionalPropertiesIsAnyType(true); property.setAdditionalPropertiesIsAnyType(true);
} }
if (m != null && isAdditionalPropertiesTrue) { if (m != null) {
m.isAdditionalPropertiesTrue = true; m.isAdditionalPropertiesTrue = isAdditionalPropertiesTrue;
m.isAdditionalPropertiesAnyType = additionalPropertiesIsAnyType;
m.isAdditionalPropertiesFreeFormObject = isAdditionalPropertiesFreeFormObject;
} }
if (ModelUtils.isComposedSchema(schema) && !supportsAdditionalPropertiesWithComposedSchema) { if (ModelUtils.isComposedSchema(schema) && !supportsAdditionalPropertiesWithComposedSchema) {
return; return;

View File

@ -1,4 +1,4 @@
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
/** /**
* A container for additional, undeclared properties. * A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with * This is a holder for any undeclared properties as specified with
@ -43,4 +43,4 @@
} }
return this.additionalProperties.get(key); return this.additionalProperties.get(key);
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}

View File

@ -314,8 +314,8 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
}{{#hasVars}} }{{#hasVars}}
{{classname}} {{classVarName}} = ({{classname}}) o; {{classname}} {{classVarName}} = ({{classname}}) o;
return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} && return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} &&
{{/-last}}{{/vars}}{{#isAdditionalPropertiesTrue}}&& {{/-last}}{{/vars}}{{#isAdditionalPropertiesEnabled}}&&
Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/isAdditionalPropertiesTrue}}{{#parent}} && Objects.equals(this.additionalProperties, {{classVarName}}.additionalProperties){{/isAdditionalPropertiesEnabled}}{{#parent}} &&
super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}}
return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}} return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}}
{{/useReflectionEqualsHashCode}} {{/useReflectionEqualsHashCode}}
@ -331,7 +331,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
return HashCodeBuilder.reflectionHashCode(this); return HashCodeBuilder.reflectionHashCode(this);
{{/useReflectionEqualsHashCode}} {{/useReflectionEqualsHashCode}}
{{^useReflectionEqualsHashCode}} {{^useReflectionEqualsHashCode}}
return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#isAdditionalPropertiesTrue}}{{#hasVars}}, {{/hasVars}}{{^hasVars}}{{#parent}}, {{/parent}}{{/hasVars}}additionalProperties{{/isAdditionalPropertiesTrue}}); return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}{{#isAdditionalPropertiesEnabled}}{{#hasVars}}, {{/hasVars}}{{^hasVars}}{{#parent}}, {{/parent}}{{/hasVars}}additionalProperties{{/isAdditionalPropertiesEnabled}});
{{/useReflectionEqualsHashCode}} {{/useReflectionEqualsHashCode}}
}{{#vendorExtensions.x-jackson-optional-nullable-helpers}} }{{#vendorExtensions.x-jackson-optional-nullable-helpers}}
@ -352,9 +352,9 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
{{#vars}} {{#vars}}
sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
sb.append("}"); sb.append("}");
return sb.toString(); return sb.toString();
} }
@ -460,7 +460,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
} }
} }
{{^hasChildren}} {{^hasChildren}}
{{^isAdditionalPropertiesTrue}} {{^isAdditionalPropertiesEnabled}}
Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet(); Set<Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields // check to see if the JSON string contains additional fields
@ -469,7 +469,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `{{classname}}` properties. JSON: %s", entry.getKey(), jsonElement.toString())); throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `{{classname}}` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
} }
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{#requiredVars}} {{#requiredVars}}
{{#-first}} {{#-first}}
@ -589,7 +589,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
@Override @Override
public void write(JsonWriter out, {{classname}} value) throws IOException { public void write(JsonWriter out, {{classname}} value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
obj.remove("additionalProperties"); obj.remove("additionalProperties");
// serialize additional properties // serialize additional properties
if (value.getAdditionalProperties() != null) { if (value.getAdditionalProperties() != null) {
@ -607,7 +607,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
} }
} }
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
elementAdapter.write(out, obj); elementAdapter.write(out, obj);
} }
@ -615,7 +615,7 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
public {{classname}} read(JsonReader in) throws IOException { public {{classname}} read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in); JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement); validateJsonElement(jsonElement);
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
JsonObject jsonObj = jsonElement.getAsJsonObject(); JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance // store additional fields in the deserialized instance
{{classname}} instance = thisAdapter.fromJsonTree(jsonObj); {{classname}} instance = thisAdapter.fromJsonTree(jsonObj);
@ -638,10 +638,10 @@ public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtens
} }
} }
return instance; return instance;
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{^isAdditionalPropertiesTrue}} {{^isAdditionalPropertiesEnabled}}
return thisAdapter.fromJsonTree(jsonElement); return thisAdapter.fromJsonTree(jsonElement);
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
} }
}.nullSafe(); }.nullSafe();

View File

@ -97,15 +97,15 @@
/// Initializes a new instance of the <see cref="{{classname}}" /> class. /// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary> /// </summary>
[JsonConstructorAttribute] [JsonConstructorAttribute]
{{^isAdditionalPropertiesTrue}} {{^isAdditionalPropertiesEnabled}}
protected {{classname}}() { } protected {{classname}}() { }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
protected {{classname}}() protected {{classname}}()
{ {
this.AdditionalProperties = new Dictionary<string, object>(); this.AdditionalProperties = new Dictionary<string, object>();
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{/hasOnlyReadOnly}} {{/hasOnlyReadOnly}}
{{/hasRequired}} {{/hasRequired}}
/// <summary> /// <summary>
@ -170,9 +170,9 @@
{{/isReadOnly}} {{/isReadOnly}}
{{/isInherited}} {{/isInherited}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
this.AdditionalProperties = new Dictionary<string, object>(); this.AdditionalProperties = new Dictionary<string, object>();
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
} }
{{#vars}} {{#vars}}
@ -250,14 +250,14 @@
{{/isEnum}} {{/isEnum}}
{{/isInherited}} {{/isInherited}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
/// <summary> /// <summary>
/// Gets or Sets additional properties /// Gets or Sets additional properties
/// </summary> /// </summary>
[JsonExtensionData] [JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; } public IDictionary<string, object> AdditionalProperties { get; set; }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -272,9 +272,9 @@
{{#vars}} {{#vars}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n"); sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -333,10 +333,10 @@
{{^vendorExtensions.x-is-value-type}}this.{{name}} != null && {{^vendorExtensions.x-is-value-type}}this.{{name}} != null &&
input.{{name}} != null && input.{{name}} != null &&
{{/vendorExtensions.x-is-value-type}}this.{{name}}.SequenceEqual(input.{{name}}) {{/vendorExtensions.x-is-value-type}}this.{{name}}.SequenceEqual(input.{{name}})
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}} ){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesEnabled}};{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
&& (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any());
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{/useCompareNetObjects}} {{/useCompareNetObjects}}
} }
@ -363,10 +363,10 @@
hashCode = hashCode * 59 + this.{{name}}.GetHashCode(); hashCode = hashCode * 59 + this.{{name}}.GetHashCode();
{{/vendorExtensions.x-is-value-type}} {{/vendorExtensions.x-is-value-type}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
if (this.AdditionalProperties != null) if (this.AdditionalProperties != null)
hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode(); hashCode = hashCode * 59 + this.AdditionalProperties.GetHashCode();
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
return hashCode; return hashCode;
} }
} }

View File

@ -168,7 +168,7 @@
{{/isInherited}} {{/isInherited}}
{{/isEnum}} {{/isEnum}}
{{/allVars}} {{/allVars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
{{^parentModel}} {{^parentModel}}
/// <summary> /// <summary>
/// Gets or Sets additional properties /// Gets or Sets additional properties
@ -177,7 +177,7 @@
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>(); public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
{{/parentModel}} {{/parentModel}}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -192,11 +192,11 @@
{{#vars}} {{#vars}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n"); sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
{{^parentModel}} {{^parentModel}}
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
{{/parentModel}} {{/parentModel}}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -249,12 +249,12 @@
{{^vendorExtensions.x-is-value-type}}{{name}} != null && {{^vendorExtensions.x-is-value-type}}{{name}} != null &&
input.{{name}} != null && input.{{name}} != null &&
{{/vendorExtensions.x-is-value-type}}{{name}}.SequenceEqual(input.{{name}}) {{/vendorExtensions.x-is-value-type}}{{name}}.SequenceEqual(input.{{name}})
){{^-last}} && {{/-last}}{{/isContainer}}{{/isInherited}}{{/readOnlyVars}}{{^readOnlyVars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/readOnlyVars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}} ){{^-last}} && {{/-last}}{{/isContainer}}{{/isInherited}}{{/readOnlyVars}}{{^readOnlyVars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/readOnlyVars}}{{^isAdditionalPropertiesEnabled}};{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
{{^parentModel}} {{^parentModel}}
&& (AdditionalProperties.Count == input.AdditionalProperties.Count && !AdditionalProperties.Except(input.AdditionalProperties).Any()); && (AdditionalProperties.Count == input.AdditionalProperties.Count && !AdditionalProperties.Except(input.AdditionalProperties).Any());
{{/parentModel}} {{/parentModel}}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{/useCompareNetObjects}} {{/useCompareNetObjects}}
} }
@ -284,11 +284,11 @@
hashCode = (hashCode * 59) + {{name}}.GetHashCode(); hashCode = (hashCode * 59) + {{name}}.GetHashCode();
{{/isNullable}} {{/isNullable}}
{{/readOnlyVars}} {{/readOnlyVars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
{{^parentModel}} {{^parentModel}}
hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode(); hashCode = (hashCode * 59) + AdditionalProperties.GetHashCode();
{{/parentModel}} {{/parentModel}}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
return hashCode; return hashCode;
} }

View File

@ -114,15 +114,15 @@
/// Initializes a new instance of the <see cref="{{classname}}" /> class. /// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary> /// </summary>
[JsonConstructorAttribute] [JsonConstructorAttribute]
{{^isAdditionalPropertiesTrue}} {{^isAdditionalPropertiesEnabled}}
protected {{classname}}() { } protected {{classname}}() { }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
protected {{classname}}() protected {{classname}}()
{ {
this.AdditionalProperties = new Dictionary<string, object>(); this.AdditionalProperties = new Dictionary<string, object>();
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{/hasOnlyReadOnly}} {{/hasOnlyReadOnly}}
{{/hasRequired}} {{/hasRequired}}
/// <summary> /// <summary>
@ -201,9 +201,9 @@
{{/isReadOnly}} {{/isReadOnly}}
{{/isInherited}} {{/isInherited}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
this.AdditionalProperties = new Dictionary<string, object>(); this.AdditionalProperties = new Dictionary<string, object>();
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
} }
{{#vars}} {{#vars}}
@ -290,14 +290,14 @@
{{/isEnum}} {{/isEnum}}
{{/isInherited}} {{/isInherited}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
/// <summary> /// <summary>
/// Gets or Sets additional properties /// Gets or Sets additional properties
/// </summary> /// </summary>
[JsonExtensionData] [JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; } public IDictionary<string, object> AdditionalProperties { get; set; }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -312,9 +312,9 @@
{{#vars}} {{#vars}}
sb.Append(" {{name}}: ").Append({{name}}).Append("\n"); sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -375,10 +375,10 @@
{{^vendorExtensions.x-is-value-type}}this.{{name}} != null && {{^vendorExtensions.x-is-value-type}}this.{{name}} != null &&
input.{{name}} != null && input.{{name}} != null &&
{{/vendorExtensions.x-is-value-type}}this.{{name}}.SequenceEqual(input.{{name}}) {{/vendorExtensions.x-is-value-type}}this.{{name}}.SequenceEqual(input.{{name}})
){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesTrue}};{{/isAdditionalPropertiesTrue}} ){{^-last}} && {{/-last}}{{/isContainer}}{{/vars}}{{^vars}}{{#parent}}base.Equals(input){{/parent}}{{^parent}}false{{/parent}}{{/vars}}{{^isAdditionalPropertiesEnabled}};{{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
&& (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any());
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{/useCompareNetObjects}} {{/useCompareNetObjects}}
} }
@ -407,12 +407,12 @@
hashCode = (hashCode * 59) + this.{{name}}.GetHashCode(); hashCode = (hashCode * 59) + this.{{name}}.GetHashCode();
{{/vendorExtensions.x-is-value-type}} {{/vendorExtensions.x-is-value-type}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
if (this.AdditionalProperties != null) if (this.AdditionalProperties != null)
{ {
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
return hashCode; return hashCode;
} }
} }

View File

@ -400,9 +400,9 @@ func (c *{{classname}}Controller) {{nickname}}(w http.ResponseWriter, r *http.Re
{{#isBodyParam}} {{#isBodyParam}}
{{paramName}}Param := {{dataType}}{} {{paramName}}Param := {{dataType}}{}
d := json.NewDecoder(r.Body) d := json.NewDecoder(r.Body)
{{^isAdditionalPropertiesTrue}} {{^isAdditionalPropertiesEnabled}}
d.DisallowUnknownFields() d.DisallowUnknownFields()
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
if err := d.Decode(&{{paramName}}Param); err != nil { if err := d.Decode(&{{paramName}}Param); err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil) c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return return

View File

@ -24,15 +24,15 @@ type {{classname}} struct {
{{/deprecated}} {{/deprecated}}
{{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}` {{name}} {{^required}}{{^isNullable}}{{^isArray}}{{^isFreeFormObject}}*{{/isFreeFormObject}}{{/isArray}}{{/isNullable}}{{/required}}{{{dataType}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}{{#isXmlAttribute}},attr{{/isXmlAttribute}}"{{/withXml}}{{#vendorExtensions.x-go-custom-tag}} {{{.}}}{{/vendorExtensions.x-go-custom-tag}}`
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
AdditionalProperties map[string]interface{} AdditionalProperties map[string]interface{}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
} }
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
type _{{{classname}}} {{{classname}}} type _{{{classname}}} {{{classname}}}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
// New{{classname}} instantiates a new {{classname}} object // New{{classname}} instantiates a new {{classname}} object
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
@ -321,17 +321,17 @@ func (o {{classname}}) ToMap() (map[string]interface{}, error) {
{{/required}} {{/required}}
{{/isNullable}} {{/isNullable}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
for key, value := range o.AdditionalProperties { for key, value := range o.AdditionalProperties {
toSerialize[key] = value toSerialize[key] = value
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
return toSerialize, nil return toSerialize, nil
} }
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) { func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
{{#parent}} {{#parent}}
{{^isMap}} {{^isMap}}
@ -440,7 +440,7 @@ func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
{{/parent}} {{/parent}}
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{#isArray}} {{#isArray}}
func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) { func (o *{{{classname}}}) UnmarshalJSON(bytes []byte) (err error) {
return json.Unmarshal(bytes, &o.Items) return json.Unmarshal(bytes, &o.Items)

View File

@ -223,24 +223,24 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
$PSBoundParameters | Out-DebugParameter | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug
$JsonParameters = ConvertFrom-Json -InputObject $Json $JsonParameters = ConvertFrom-Json -InputObject $Json
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties = @{} ${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties = @{}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
# check if Json contains properties not defined in {{{apiNamePrefix}}}{{{classname}}} # check if Json contains properties not defined in {{{apiNamePrefix}}}{{{classname}}}
$AllProperties = ({{#allVars}}"{{{baseName}}}"{{^-last}}, {{/-last}}{{/allVars}}) $AllProperties = ({{#allVars}}"{{{baseName}}}"{{^-last}}, {{/-last}}{{/allVars}})
foreach ($name in $JsonParameters.PsObject.Properties.Name) { foreach ($name in $JsonParameters.PsObject.Properties.Name) {
{{^isAdditionalPropertiesTrue}} {{^isAdditionalPropertiesEnabled}}
if (!($AllProperties.Contains($name))) { if (!($AllProperties.Contains($name))) {
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
# store undefined properties in additionalProperties # store undefined properties in additionalProperties
if (!($AllProperties.Contains($name))) { if (!($AllProperties.Contains($name))) {
${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value ${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
} }
{{#requiredVars}} {{#requiredVars}}
@ -271,9 +271,9 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
"<<baseName>>" = ${<<name>>} "<<baseName>>" = ${<<name>>}
<</allVars>> <</allVars>>
<<={{ }}=>> <<={{ }}=>>
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
"AdditionalProperties" = ${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties "AdditionalProperties" = ${{{apiNamePrefix}}}{{{classname}}}AdditionalProperties
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
} }
return $PSO return $PSO

View File

@ -22,9 +22,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#vars}} {{#vars}}
{{name}}: {{{vendorExtensions.x-py-typing}}} {{name}}: {{{vendorExtensions.x-py-typing}}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
additional_properties: Dict[str, Any] = {} additional_properties: Dict[str, Any] = {}
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
__properties = [{{#allVars}}"{{baseName}}"{{^-last}}, {{/-last}}{{/allVars}}] __properties = [{{#allVars}}"{{baseName}}"{{^-last}}, {{/-last}}{{/allVars}}]
{{#vars}} {{#vars}}
{{#vendorExtensions.x-regex}} {{#vendorExtensions.x-regex}}
@ -130,9 +130,9 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{#vendorExtensions.x-py-readonly}} {{#vendorExtensions.x-py-readonly}}
"{{{.}}}", "{{{.}}}",
{{/vendorExtensions.x-py-readonly}} {{/vendorExtensions.x-py-readonly}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
"additional_properties" "additional_properties"
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
}, },
exclude_none=True) exclude_none=True)
{{#allVars}} {{#allVars}}
@ -202,13 +202,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/isContainer}} {{/isContainer}}
{{/allVars}} {{/allVars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
# puts key-value pairs in additional_properties in the top level # puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None: if self.additional_properties is not None:
for _key, _value in self.additional_properties.items(): for _key, _value in self.additional_properties.items():
_dict[_key] = _value _dict[_key] = _value
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{#allVars}} {{#allVars}}
{{#isNullable}} {{#isNullable}}
# set to None if {{{name}}} (nullable) is None # set to None if {{{name}}} (nullable) is None
@ -244,13 +244,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
return {{{classname}}}.parse_obj(obj) return {{{classname}}}.parse_obj(obj)
{{#disallowAdditionalPropertiesIfNotPresent}} {{#disallowAdditionalPropertiesIfNotPresent}}
{{^isAdditionalPropertiesTrue}} {{^isAdditionalPropertiesEnabled}}
# raise errors for additional fields in the input # raise errors for additional fields in the input
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties:
raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + obj) raise ValueError("Error due to additional fields (not defined in {{classname}}) in the input: " + obj)
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{/disallowAdditionalPropertiesIfNotPresent}} {{/disallowAdditionalPropertiesIfNotPresent}}
_obj = {{{classname}}}.parse_obj({ _obj = {{{classname}}}.parse_obj({
{{#allVars}} {{#allVars}}
@ -348,13 +348,13 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{/isContainer}} {{/isContainer}}
{{/allVars}} {{/allVars}}
}) })
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
# store additional fields in additional_properties # store additional fields in additional_properties
for _key in obj.keys(): for _key in obj.keys():
if _key not in cls.__properties: if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key) _obj.additional_properties[_key] = obj.get(_key)
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
return _obj return _obj
{{/hasChildren}} {{/hasChildren}}
@ -363,4 +363,4 @@ class {{classname}}({{#parent}}{{{.}}}{{/parent}}{{^parent}}BaseModel{{/parent}}
{{{.}}} {{{.}}}
{{/vendorExtensions.x-py-postponed-model-imports}} {{/vendorExtensions.x-py-postponed-model-imports}}
{{classname}}.update_forward_refs() {{classname}}.update_forward_refs()
{{/vendorExtensions.x-py-postponed-model-imports.size}} {{/vendorExtensions.x-py-postponed-model-imports.size}}

View File

@ -10,10 +10,10 @@
{{#vars}} {{#vars}}
#' @field {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}} {{{vendorExtensions.x-r-doc-type}}}{{^required}} [optional]{{/required}} #' @field {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}} {{{vendorExtensions.x-r-doc-type}}}{{^required}} [optional]{{/required}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
#' @field _field_list a list of fields list(character) #' @field _field_list a list of fields list(character)
#' @field additional_properties additional properties list(character) [optional] #' @field additional_properties additional properties list(character) [optional]
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
#' @importFrom R6 R6Class #' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON #' @importFrom jsonlite fromJSON toJSON
#' @export #' @export
@ -26,10 +26,10 @@
{{#vars}} {{#vars}}
`{{{name}}}` = NULL, `{{{name}}}` = NULL,
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
`_field_list` = c({{#vars}}"{{{name}}}"{{^-last}}, {{/-last}}{{/vars}}), `_field_list` = c({{#vars}}"{{{name}}}"{{^-last}}, {{/-last}}{{/vars}}),
`additional_properties` = list(), `additional_properties` = list(),
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{#discriminator}} {{#discriminator}}
`_discriminator_property_name` = '{{discriminator.propertyName}}', `_discriminator_property_name` = '{{discriminator.propertyName}}',
{{#discriminator.mappedModels}}{{#-first}}`_discriminator_mapping_name` = c({{/-first}}'{{mappingName}}' = '{{modelName}}'{{^-last}}, {{/-last}}{{#-last}}),{{/-last}}{{/discriminator.mappedModels}} {{#discriminator.mappedModels}}{{#-first}}`_discriminator_mapping_name` = c({{/-first}}'{{mappingName}}' = '{{modelName}}'{{^-last}}, {{/-last}}{{#-last}}),{{/-last}}{{/discriminator.mappedModels}}
@ -45,12 +45,12 @@
{{#optionalVars}} {{#optionalVars}}
#' @param {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}}{{^description}}{{{name}}}{{/description}}{{#defaultValue}}. Default to {{{.}}}.{{/defaultValue}} #' @param {{name}} {{#lambdaRdocEscape}}{{{description}}}{{/lambdaRdocEscape}}{{^description}}{{{name}}}{{/description}}{{#defaultValue}}. Default to {{{.}}}.{{/defaultValue}}
{{/optionalVars}} {{/optionalVars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
#' @param additional_properties additional properties (optional) #' @param additional_properties additional properties (optional)
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
#' @param ... Other optional arguments. #' @param ... Other optional arguments.
#' @export #' @export
initialize = function({{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}` = {{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}{{#isAdditionalPropertiesTrue}}additional_properties = NULL, {{/isAdditionalPropertiesTrue}}...) { initialize = function({{#requiredVars}}`{{name}}`, {{/requiredVars}}{{#optionalVars}}`{{name}}` = {{{defaultValue}}}{{^defaultValue}}NULL{{/defaultValue}}, {{/optionalVars}}{{#isAdditionalPropertiesEnabled}}additional_properties = NULL, {{/isAdditionalPropertiesEnabled}}...) {
{{#requiredVars}} {{#requiredVars}}
if (!missing(`{{name}}`)) { if (!missing(`{{name}}`)) {
{{^isContainer}} {{^isContainer}}
@ -195,13 +195,13 @@
self$`{{name}}` <- `{{name}}` self$`{{name}}` <- `{{name}}`
} }
{{/optionalVars}} {{/optionalVars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
if (!is.null(additional_properties)) { if (!is.null(additional_properties)) {
for (key in names(additional_properties)) { for (key in names(additional_properties)) {
self$additional_properties[[key]] <- additional_properties[[key]] self$additional_properties[[key]] <- additional_properties[[key]]
} }
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
}, },
#' To JSON string #' To JSON string
#' #'
@ -243,12 +243,12 @@
{{/isContainer}} {{/isContainer}}
} }
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
{{classname}}Object[[key]] <- self$additional_properties[[key]] {{classname}}Object[[key]] <- self$additional_properties[[key]]
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
{{classname}}Object {{classname}}Object
}, },
#' Deserialize JSON string into an instance of {{{classname}}} #' Deserialize JSON string into an instance of {{{classname}}}
@ -296,7 +296,7 @@
{{/isContainer}} {{/isContainer}}
} }
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
# process additional properties/fields in the payload # process additional properties/fields in the payload
for (key in names(this_object)) { for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields if (!(key %in% self$`_field_list`)) { # json key not in list of fields
@ -304,7 +304,7 @@
} }
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
self self
}, },
#' To JSON string #' To JSON string
@ -375,13 +375,13 @@
) )
jsoncontent <- paste(jsoncontent, collapse = ",") jsoncontent <- paste(jsoncontent, collapse = ",")
json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = ""))) json_string <- as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
json_obj <- jsonlite::fromJSON(json_string) json_obj <- jsonlite::fromJSON(json_string)
for (key in names(self$additional_properties)) { for (key in names(self$additional_properties)) {
json_obj[[key]] <- self$additional_properties[[key]] json_obj[[key]] <- self$additional_properties[[key]]
} }
json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA))) json_string <- as.character(jsonlite::minify(jsonlite::toJSON(json_obj, auto_unbox = TRUE, digits = NA)))
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
}, },
#' Deserialize JSON string into an instance of {{{classname}}} #' Deserialize JSON string into an instance of {{{classname}}}
#' #'
@ -425,7 +425,7 @@
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/isContainer}} {{/isContainer}}
{{/vars}} {{/vars}}
{{#isAdditionalPropertiesTrue}} {{#isAdditionalPropertiesEnabled}}
# process additional properties/fields in the payload # process additional properties/fields in the payload
for (key in names(this_object)) { for (key in names(this_object)) {
if (!(key %in% self$`_field_list`)) { # json key not in list of fields if (!(key %in% self$`_field_list`)) { # json key not in list of fields
@ -433,7 +433,7 @@
} }
} }
{{/isAdditionalPropertiesTrue}} {{/isAdditionalPropertiesEnabled}}
self self
}, },
#' Validate JSON input with respect to {{classname}} #' Validate JSON input with respect to {{classname}}

View File

@ -2246,3 +2246,16 @@ components:
description: Property description: Property
type: boolean type: boolean
default: false default: false
AdditionalPropertieObject:
type: object
properties:
name:
type: string
additionalProperties:
type: object
AdditionalPropertieAnyType:
type: object
properties:
name:
type: string
additionalProperties: {}

View File

@ -109,6 +109,7 @@ namespace Org.OpenAPITools.Model
{ {
this._flagObjectItemsNullable = true; this._flagObjectItemsNullable = true;
} }
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -400,6 +401,12 @@ namespace Org.OpenAPITools.Model
{ {
return _flagObjectItemsNullable; return _flagObjectItemsNullable;
} }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -421,6 +428,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -511,6 +519,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -137,6 +137,12 @@ namespace Org.OpenAPITools.Model
[JsonPropertyName("string_prop")] [JsonPropertyName("string_prop")]
public string? StringProp { get; set; } public string? StringProp { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -158,6 +164,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" StringProp: ").Append(StringProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }

View File

@ -135,6 +135,12 @@ namespace Org.OpenAPITools.Model
[JsonPropertyName("string_prop")] [JsonPropertyName("string_prop")]
public string StringProp { get; set; } public string StringProp { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -156,6 +162,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" StringProp: ").Append(StringProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }

View File

@ -135,6 +135,12 @@ namespace Org.OpenAPITools.Model
[JsonPropertyName("string_prop")] [JsonPropertyName("string_prop")]
public string StringProp { get; set; } public string StringProp { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -156,6 +162,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" StringProp: ").Append(StringProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }

View File

@ -62,6 +62,7 @@ namespace Org.OpenAPITools.Model
this.ObjectNullableProp = objectNullableProp; this.ObjectNullableProp = objectNullableProp;
this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp;
this.ObjectItemsNullable = objectItemsNullable; this.ObjectItemsNullable = objectItemsNullable;
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -137,6 +138,12 @@ namespace Org.OpenAPITools.Model
[DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)]
public Dictionary<string, Object> ObjectItemsNullable { get; set; } public Dictionary<string, Object> ObjectItemsNullable { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -158,6 +165,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -248,6 +256,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model
this.ObjectNullableProp = objectNullableProp; this.ObjectNullableProp = objectNullableProp;
this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp;
this.ObjectItemsNullable = objectItemsNullable; this.ObjectItemsNullable = objectItemsNullable;
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model
[DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)]
public Dictionary<string, Object> ObjectItemsNullable { get; set; } public Dictionary<string, Object> ObjectItemsNullable { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model
this.ObjectNullableProp = objectNullableProp; this.ObjectNullableProp = objectNullableProp;
this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp;
this.ObjectItemsNullable = objectItemsNullable; this.ObjectItemsNullable = objectItemsNullable;
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model
[DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)]
public Dictionary<string, Object> ObjectItemsNullable { get; set; } public Dictionary<string, Object> ObjectItemsNullable { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model
this.ObjectNullableProp = objectNullableProp; this.ObjectNullableProp = objectNullableProp;
this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp;
this.ObjectItemsNullable = objectItemsNullable; this.ObjectItemsNullable = objectItemsNullable;
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model
[DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)]
public Dictionary<string, Object> ObjectItemsNullable { get; set; } public Dictionary<string, Object> ObjectItemsNullable { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model
this.ObjectNullableProp = objectNullableProp; this.ObjectNullableProp = objectNullableProp;
this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp;
this.ObjectItemsNullable = objectItemsNullable; this.ObjectItemsNullable = objectItemsNullable;
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -134,6 +135,12 @@ namespace Org.OpenAPITools.Model
[DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)]
public Dictionary<string, Object> ObjectItemsNullable { get; set; } public Dictionary<string, Object> ObjectItemsNullable { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -155,6 +162,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -255,7 +263,8 @@ namespace Org.OpenAPITools.Model
this.ObjectItemsNullable != null && this.ObjectItemsNullable != null &&
input.ObjectItemsNullable != null && input.ObjectItemsNullable != null &&
this.ObjectItemsNullable.SequenceEqual(input.ObjectItemsNullable) this.ObjectItemsNullable.SequenceEqual(input.ObjectItemsNullable)
); )
&& (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any());
} }
/// <summary> /// <summary>
@ -315,6 +324,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model
this.ObjectNullableProp = objectNullableProp; this.ObjectNullableProp = objectNullableProp;
this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp;
this.ObjectItemsNullable = objectItemsNullable; this.ObjectItemsNullable = objectItemsNullable;
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model
[DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)]
public Dictionary<string, Object> ObjectItemsNullable { get; set; } public Dictionary<string, Object> ObjectItemsNullable { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model
this.ObjectNullableProp = objectNullableProp; this.ObjectNullableProp = objectNullableProp;
this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp;
this.ObjectItemsNullable = objectItemsNullable; this.ObjectItemsNullable = objectItemsNullable;
this.AdditionalProperties = new Dictionary<string, object>();
} }
/// <summary> /// <summary>
@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model
[DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)]
public Dictionary<string, Object> ObjectItemsNullable { get; set; } public Dictionary<string, Object> ObjectItemsNullable { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model
sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n");
sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n");
sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n");
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
sb.Append("}\n"); sb.Append("}\n");
return sb.ToString(); return sb.ToString();
} }
@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model
{ {
hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode();
} }
if (this.AdditionalProperties != null)
{
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
}
return hashCode; return hashCode;
} }
} }

View File

@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesAnyType{}
// AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType // AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType
type AdditionalPropertiesAnyType struct { type AdditionalPropertiesAnyType struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
AdditionalProperties map[string]interface{}
} }
type _AdditionalPropertiesAnyType AdditionalPropertiesAnyType
// NewAdditionalPropertiesAnyType instantiates a new AdditionalPropertiesAnyType object // NewAdditionalPropertiesAnyType instantiates a new AdditionalPropertiesAnyType object
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
@ -84,9 +87,31 @@ func (o AdditionalPropertiesAnyType) ToMap() (map[string]interface{}, error) {
if !IsNil(o.Name) { if !IsNil(o.Name) {
toSerialize["name"] = o.Name toSerialize["name"] = o.Name
} }
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil return toSerialize, nil
} }
func (o *AdditionalPropertiesAnyType) UnmarshalJSON(bytes []byte) (err error) {
varAdditionalPropertiesAnyType := _AdditionalPropertiesAnyType{}
if err = json.Unmarshal(bytes, &varAdditionalPropertiesAnyType); err == nil {
*o = AdditionalPropertiesAnyType(varAdditionalPropertiesAnyType)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
delete(additionalProperties, "name")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableAdditionalPropertiesAnyType struct { type NullableAdditionalPropertiesAnyType struct {
value *AdditionalPropertiesAnyType value *AdditionalPropertiesAnyType
isSet bool isSet bool

View File

@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesObject{}
// AdditionalPropertiesObject struct for AdditionalPropertiesObject // AdditionalPropertiesObject struct for AdditionalPropertiesObject
type AdditionalPropertiesObject struct { type AdditionalPropertiesObject struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
AdditionalProperties map[string]interface{}
} }
type _AdditionalPropertiesObject AdditionalPropertiesObject
// NewAdditionalPropertiesObject instantiates a new AdditionalPropertiesObject object // NewAdditionalPropertiesObject instantiates a new AdditionalPropertiesObject object
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
@ -84,9 +87,31 @@ func (o AdditionalPropertiesObject) ToMap() (map[string]interface{}, error) {
if !IsNil(o.Name) { if !IsNil(o.Name) {
toSerialize["name"] = o.Name toSerialize["name"] = o.Name
} }
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil return toSerialize, nil
} }
func (o *AdditionalPropertiesObject) UnmarshalJSON(bytes []byte) (err error) {
varAdditionalPropertiesObject := _AdditionalPropertiesObject{}
if err = json.Unmarshal(bytes, &varAdditionalPropertiesObject); err == nil {
*o = AdditionalPropertiesObject(varAdditionalPropertiesObject)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
delete(additionalProperties, "name")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableAdditionalPropertiesObject struct { type NullableAdditionalPropertiesObject struct {
value *AdditionalPropertiesObject value *AdditionalPropertiesObject
isSet bool isSet bool

View File

@ -79,6 +79,50 @@ public class AdditionalPropertiesAnyType {
this.name = name; 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 @Override
@ -90,12 +134,13 @@ public class AdditionalPropertiesAnyType {
return false; return false;
} }
AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name); return Objects.hash(name, additionalProperties);
} }
@Override @Override
@ -103,6 +148,7 @@ public class AdditionalPropertiesAnyType {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class AdditionalPropertiesAnyType {\n"); sb.append("class AdditionalPropertiesAnyType {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}"); sb.append("}");
return sb.toString(); 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())); 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(); JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { 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())); 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 @Override
public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException { public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); 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); elementAdapter.write(out, obj);
} }
@ -179,7 +234,28 @@ public class AdditionalPropertiesAnyType {
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException { public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in); JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement); 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(); }.nullSafe();

View File

@ -80,6 +80,50 @@ public class AdditionalPropertiesObject {
this.name = name; 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 @Override
@ -91,12 +135,13 @@ public class AdditionalPropertiesObject {
return false; return false;
} }
AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name); return Objects.hash(name, additionalProperties);
} }
@Override @Override
@ -104,6 +149,7 @@ public class AdditionalPropertiesObject {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class AdditionalPropertiesObject {\n"); sb.append("class AdditionalPropertiesObject {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}"); sb.append("}");
return sb.toString(); 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())); 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(); JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { 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())); 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 @Override
public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException { public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); 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); elementAdapter.write(out, obj);
} }
@ -180,7 +235,28 @@ public class AdditionalPropertiesObject {
public AdditionalPropertiesObject read(JsonReader in) throws IOException { public AdditionalPropertiesObject read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in); JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement); 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(); }.nullSafe();

View File

@ -81,6 +81,50 @@ public class AdditionalPropertiesAnyType implements Parcelable {
this.name = name; 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 @Override
@ -92,12 +136,13 @@ public class AdditionalPropertiesAnyType implements Parcelable {
return false; return false;
} }
AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name); return Objects.hash(name, additionalProperties);
} }
@Override @Override
@ -105,6 +150,7 @@ public class AdditionalPropertiesAnyType implements Parcelable {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class AdditionalPropertiesAnyType {\n"); sb.append("class AdditionalPropertiesAnyType {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}"); sb.append("}");
return sb.toString(); 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())); 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(); JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { 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())); 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 @Override
public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException { public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); 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); elementAdapter.write(out, obj);
} }
@ -202,7 +257,28 @@ public class AdditionalPropertiesAnyType implements Parcelable {
public AdditionalPropertiesAnyType read(JsonReader in) throws IOException { public AdditionalPropertiesAnyType read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in); JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement); 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(); }.nullSafe();

View File

@ -82,6 +82,50 @@ public class AdditionalPropertiesObject implements Parcelable {
this.name = name; 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 @Override
@ -93,12 +137,13 @@ public class AdditionalPropertiesObject implements Parcelable {
return false; return false;
} }
AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; 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 @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name); return Objects.hash(name, additionalProperties);
} }
@Override @Override
@ -106,6 +151,7 @@ public class AdditionalPropertiesObject implements Parcelable {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class AdditionalPropertiesObject {\n"); sb.append("class AdditionalPropertiesObject {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}"); sb.append("}");
return sb.toString(); 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())); 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(); JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { 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())); 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 @Override
public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException { public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); 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); elementAdapter.write(out, obj);
} }
@ -203,7 +258,28 @@ public class AdditionalPropertiesObject implements Parcelable {
public AdditionalPropertiesObject read(JsonReader in) throws IOException { public AdditionalPropertiesObject read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in); JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement); 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(); }.nullSafe();

View File

@ -410,6 +410,50 @@ public class NullableClass {
this.objectItemsNullable = objectItemsNullable; 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 @Override
@ -432,7 +476,8 @@ public class NullableClass {
Objects.equals(this.arrayItemsNullable, nullableClass.arrayItemsNullable) && Objects.equals(this.arrayItemsNullable, nullableClass.arrayItemsNullable) &&
Objects.equals(this.objectNullableProp, nullableClass.objectNullableProp) && Objects.equals(this.objectNullableProp, nullableClass.objectNullableProp) &&
Objects.equals(this.objectAndItemsNullableProp, nullableClass.objectAndItemsNullableProp) && 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) { private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
@ -441,7 +486,7 @@ public class NullableClass {
@Override @Override
public int hashCode() { 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) { 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(" objectNullableProp: ").append(toIndentedString(objectNullableProp)).append("\n");
sb.append(" objectAndItemsNullableProp: ").append(toIndentedString(objectAndItemsNullableProp)).append("\n"); sb.append(" objectAndItemsNullableProp: ").append(toIndentedString(objectAndItemsNullableProp)).append("\n");
sb.append(" objectItemsNullable: ").append(toIndentedString(objectItemsNullable)).append("\n"); sb.append(" objectItemsNullable: ").append(toIndentedString(objectItemsNullable)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n");
sb.append("}"); sb.append("}");
return sb.toString(); 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())); 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(); JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("string_prop") != null && !jsonObj.get("string_prop").isJsonNull()) && !jsonObj.get("string_prop").isJsonPrimitive()) { 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())); 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 @Override
public void write(JsonWriter out, NullableClass value) throws IOException { public void write(JsonWriter out, NullableClass value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); 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); elementAdapter.write(out, obj);
} }
@ -566,7 +621,28 @@ public class NullableClass {
public NullableClass read(JsonReader in) throws IOException { public NullableClass read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in); JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement); 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(); }.nullSafe();

View File

@ -137,12 +137,14 @@ function ConvertFrom-PSJsonToNullableClass {
$PSBoundParameters | Out-DebugParameter | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug
$JsonParameters = ConvertFrom-Json -InputObject $Json $JsonParameters = ConvertFrom-Json -InputObject $Json
$PSNullableClassAdditionalProperties = @{}
# check if Json contains properties not defined in PSNullableClass # check if Json contains properties not defined in PSNullableClass
$AllProperties = ("integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable") $AllProperties = ("integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable")
foreach ($name in $JsonParameters.PsObject.Properties.Name) { foreach ($name in $JsonParameters.PsObject.Properties.Name) {
# store undefined properties in additionalProperties
if (!($AllProperties.Contains($name))) { if (!($AllProperties.Contains($name))) {
throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" $PSNullableClassAdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value
} }
} }
@ -231,6 +233,7 @@ function ConvertFrom-PSJsonToNullableClass {
"object_nullable_prop" = ${ObjectNullableProp} "object_nullable_prop" = ${ObjectNullableProp}
"object_and_items_nullable_prop" = ${ObjectAndItemsNullableProp} "object_and_items_nullable_prop" = ${ObjectAndItemsNullableProp}
"object_items_nullable" = ${ObjectItemsNullable} "object_items_nullable" = ${ObjectItemsNullable}
"AdditionalProperties" = $PSNullableClassAdditionalProperties
} }
return $PSO return $PSO

View File

@ -1656,7 +1656,7 @@ export interface Whale {
* @interface Zebra * @interface Zebra
*/ */
export interface Zebra { export interface Zebra {
[key: string]: any; [key: string]: any | any;
/** /**
* *

View File

@ -175,7 +175,7 @@ export interface ArrayTest {
* @interface Banana * @interface Banana
*/ */
export interface Banana { export interface Banana {
[key: string]: any; [key: string]: any | any;
/** /**
* *

View File

@ -32,8 +32,11 @@ type NullableClass struct {
ObjectNullableProp map[string]map[string]interface{} `json:"object_nullable_prop,omitempty"` ObjectNullableProp map[string]map[string]interface{} `json:"object_nullable_prop,omitempty"`
ObjectAndItemsNullableProp map[string]map[string]interface{} `json:"object_and_items_nullable_prop,omitempty"` ObjectAndItemsNullableProp map[string]map[string]interface{} `json:"object_and_items_nullable_prop,omitempty"`
ObjectItemsNullable map[string]map[string]interface{} `json:"object_items_nullable,omitempty"` ObjectItemsNullable map[string]map[string]interface{} `json:"object_items_nullable,omitempty"`
AdditionalProperties map[string]interface{}
} }
type _NullableClass NullableClass
// NewNullableClass instantiates a new NullableClass object // NewNullableClass instantiates a new NullableClass object
// This constructor will assign default values to properties that have it defined, // This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments // and makes sure properties required by API are set, but the set of arguments
@ -549,9 +552,42 @@ func (o NullableClass) ToMap() (map[string]interface{}, error) {
if !IsNil(o.ObjectItemsNullable) { if !IsNil(o.ObjectItemsNullable) {
toSerialize["object_items_nullable"] = o.ObjectItemsNullable toSerialize["object_items_nullable"] = o.ObjectItemsNullable
} }
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil return toSerialize, nil
} }
func (o *NullableClass) UnmarshalJSON(bytes []byte) (err error) {
varNullableClass := _NullableClass{}
if err = json.Unmarshal(bytes, &varNullableClass); err == nil {
*o = NullableClass(varNullableClass)
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
delete(additionalProperties, "integer_prop")
delete(additionalProperties, "number_prop")
delete(additionalProperties, "boolean_prop")
delete(additionalProperties, "string_prop")
delete(additionalProperties, "date_prop")
delete(additionalProperties, "datetime_prop")
delete(additionalProperties, "array_nullable_prop")
delete(additionalProperties, "array_and_items_nullable_prop")
delete(additionalProperties, "array_items_nullable")
delete(additionalProperties, "object_nullable_prop")
delete(additionalProperties, "object_and_items_nullable_prop")
delete(additionalProperties, "object_items_nullable")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableNullableClass struct { type NullableNullableClass struct {
value *NullableClass value *NullableClass
isSet bool isSet bool

View File

@ -3,6 +3,8 @@
.gitlab-ci.yml .gitlab-ci.yml
.travis.yml .travis.yml
README.md README.md
docs/AdditionalPropertieAnyType.md
docs/AdditionalPropertieObject.md
docs/AdditionalPropertiesClass.md docs/AdditionalPropertiesClass.md
docs/AllOfWithSingleRef.md docs/AllOfWithSingleRef.md
docs/Animal.md docs/Animal.md
@ -97,6 +99,8 @@ petstore_api/api_response.py
petstore_api/configuration.py petstore_api/configuration.py
petstore_api/exceptions.py petstore_api/exceptions.py
petstore_api/models/__init__.py petstore_api/models/__init__.py
petstore_api/models/additional_propertie_any_type.py
petstore_api/models/additional_propertie_object.py
petstore_api/models/additional_properties_class.py petstore_api/models/additional_properties_class.py
petstore_api/models/all_of_with_single_ref.py petstore_api/models/all_of_with_single_ref.py
petstore_api/models/animal.py petstore_api/models/animal.py

View File

@ -132,6 +132,8 @@ Class | Method | HTTP request | Description
## Documentation For Models ## Documentation For Models
- [AdditionalPropertieAnyType](docs/AdditionalPropertieAnyType.md)
- [AdditionalPropertieObject](docs/AdditionalPropertieObject.md)
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [AllOfWithSingleRef](docs/AllOfWithSingleRef.md) - [AllOfWithSingleRef](docs/AllOfWithSingleRef.md)
- [Animal](docs/Animal.md) - [Animal](docs/Animal.md)

View File

@ -0,0 +1,28 @@
# AdditionalPropertieAnyType
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
## Example
```python
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
# TODO update the JSON string below
json = "{}"
# create an instance of AdditionalPropertieAnyType from a JSON string
additional_propertie_any_type_instance = AdditionalPropertieAnyType.from_json(json)
# print the JSON string representation of the object
print AdditionalPropertieAnyType.to_json()
# convert the object into a dict
additional_propertie_any_type_dict = additional_propertie_any_type_instance.to_dict()
# create an instance of AdditionalPropertieAnyType from a dict
additional_propertie_any_type_form_dict = additional_propertie_any_type.from_dict(additional_propertie_any_type_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,28 @@
# AdditionalPropertieObject
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
## Example
```python
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
# TODO update the JSON string below
json = "{}"
# create an instance of AdditionalPropertieObject from a JSON string
additional_propertie_object_instance = AdditionalPropertieObject.from_json(json)
# print the JSON string representation of the object
print AdditionalPropertieObject.to_json()
# convert the object into a dict
additional_propertie_object_dict = additional_propertie_object_instance.to_dict()
# create an instance of AdditionalPropertieObject from a dict
additional_propertie_object_form_dict = additional_propertie_object.from_dict(additional_propertie_object_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -38,6 +38,8 @@ from petstore_api.exceptions import ApiException
from petstore_api.signing import HttpSigningConfiguration from petstore_api.signing import HttpSigningConfiguration
# import models into sdk package # import models into sdk package
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
from petstore_api.models.animal import Animal from petstore_api.models.animal import Animal

View File

@ -14,6 +14,8 @@
# import models into model package # import models into model package
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
from petstore_api.models.animal import Animal from petstore_api.models.animal import Animal

View File

@ -0,0 +1,83 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictStr
class AdditionalPropertieAnyType(BaseModel):
"""
AdditionalPropertieAnyType
"""
name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {}
__properties = ["name"]
class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> AdditionalPropertieAnyType:
"""Create an instance of AdditionalPropertieAnyType from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
"additional_properties"
},
exclude_none=True)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
return _dict
@classmethod
def from_dict(cls, obj: dict) -> AdditionalPropertieAnyType:
"""Create an instance of AdditionalPropertieAnyType from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return AdditionalPropertieAnyType.parse_obj(obj)
_obj = AdditionalPropertieAnyType.parse_obj({
"name": obj.get("name")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj

View File

@ -0,0 +1,83 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictStr
class AdditionalPropertieObject(BaseModel):
"""
AdditionalPropertieObject
"""
name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {}
__properties = ["name"]
class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> AdditionalPropertieObject:
"""Create an instance of AdditionalPropertieObject from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
"additional_properties"
},
exclude_none=True)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
return _dict
@classmethod
def from_dict(cls, obj: dict) -> AdditionalPropertieObject:
"""Create an instance of AdditionalPropertieObject from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return AdditionalPropertieObject.parse_obj(obj)
_obj = AdditionalPropertieObject.parse_obj({
"name": obj.get("name")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj

View File

@ -38,6 +38,7 @@ class NullableClass(BaseModel):
object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None
additional_properties: Dict[str, Any] = {}
__properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] __properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"]
class Config: class Config:
@ -62,8 +63,14 @@ class NullableClass(BaseModel):
"""Returns the dictionary representation of the model using alias""" """Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True, _dict = self.dict(by_alias=True,
exclude={ exclude={
"additional_properties"
}, },
exclude_none=True) exclude_none=True)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
# set to None if required_integer_prop (nullable) is None # set to None if required_integer_prop (nullable) is None
# and __fields_set__ contains the field # and __fields_set__ contains the field
if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__: if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__:
@ -145,6 +152,11 @@ class NullableClass(BaseModel):
"object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"), "object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"),
"object_items_nullable": obj.get("object_items_nullable") "object_items_nullable": obj.get("object_items_nullable")
}) })
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -0,0 +1,54 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
import unittest
import datetime
import petstore_api
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType # noqa: E501
from petstore_api.rest import ApiException
class TestAdditionalPropertieAnyType(unittest.TestCase):
"""AdditionalPropertieAnyType unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test AdditionalPropertieAnyType
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `AdditionalPropertieAnyType`
"""
model = petstore_api.models.additional_propertie_any_type.AdditionalPropertieAnyType() # noqa: E501
if include_optional :
return AdditionalPropertieAnyType(
name = ''
)
else :
return AdditionalPropertieAnyType(
)
"""
def testAdditionalPropertieAnyType(self):
"""Test AdditionalPropertieAnyType"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,54 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
import unittest
import datetime
import petstore_api
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject # noqa: E501
from petstore_api.rest import ApiException
class TestAdditionalPropertieObject(unittest.TestCase):
"""AdditionalPropertieObject unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test AdditionalPropertieObject
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `AdditionalPropertieObject`
"""
model = petstore_api.models.additional_propertie_object.AdditionalPropertieObject() # noqa: E501
if include_optional :
return AdditionalPropertieObject(
name = ''
)
else :
return AdditionalPropertieObject(
)
"""
def testAdditionalPropertieObject(self):
"""Test AdditionalPropertieObject"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -3,6 +3,8 @@
.gitlab-ci.yml .gitlab-ci.yml
.travis.yml .travis.yml
README.md README.md
docs/AdditionalPropertieAnyType.md
docs/AdditionalPropertieObject.md
docs/AdditionalPropertiesClass.md docs/AdditionalPropertiesClass.md
docs/AllOfWithSingleRef.md docs/AllOfWithSingleRef.md
docs/Animal.md docs/Animal.md
@ -97,6 +99,8 @@ petstore_api/api_response.py
petstore_api/configuration.py petstore_api/configuration.py
petstore_api/exceptions.py petstore_api/exceptions.py
petstore_api/models/__init__.py petstore_api/models/__init__.py
petstore_api/models/additional_propertie_any_type.py
petstore_api/models/additional_propertie_object.py
petstore_api/models/additional_properties_class.py petstore_api/models/additional_properties_class.py
petstore_api/models/all_of_with_single_ref.py petstore_api/models/all_of_with_single_ref.py
petstore_api/models/animal.py petstore_api/models/animal.py

View File

@ -132,6 +132,8 @@ Class | Method | HTTP request | Description
## Documentation For Models ## Documentation For Models
- [AdditionalPropertieAnyType](docs/AdditionalPropertieAnyType.md)
- [AdditionalPropertieObject](docs/AdditionalPropertieObject.md)
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
- [AllOfWithSingleRef](docs/AllOfWithSingleRef.md) - [AllOfWithSingleRef](docs/AllOfWithSingleRef.md)
- [Animal](docs/Animal.md) - [Animal](docs/Animal.md)

View File

@ -0,0 +1,28 @@
# AdditionalPropertieAnyType
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
## Example
```python
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
# TODO update the JSON string below
json = "{}"
# create an instance of AdditionalPropertieAnyType from a JSON string
additional_propertie_any_type_instance = AdditionalPropertieAnyType.from_json(json)
# print the JSON string representation of the object
print AdditionalPropertieAnyType.to_json()
# convert the object into a dict
additional_propertie_any_type_dict = additional_propertie_any_type_instance.to_dict()
# create an instance of AdditionalPropertieAnyType from a dict
additional_propertie_any_type_form_dict = additional_propertie_any_type.from_dict(additional_propertie_any_type_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,28 @@
# AdditionalPropertieObject
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
## Example
```python
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
# TODO update the JSON string below
json = "{}"
# create an instance of AdditionalPropertieObject from a JSON string
additional_propertie_object_instance = AdditionalPropertieObject.from_json(json)
# print the JSON string representation of the object
print AdditionalPropertieObject.to_json()
# convert the object into a dict
additional_propertie_object_dict = additional_propertie_object_instance.to_dict()
# create an instance of AdditionalPropertieObject from a dict
additional_propertie_object_form_dict = additional_propertie_object.from_dict(additional_propertie_object_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,28 @@
# AdditionalPropertiesAnyType
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | | [optional]
## Example
```python
from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType
# TODO update the JSON string below
json = "{}"
# create an instance of AdditionalPropertiesAnyType from a JSON string
additional_properties_any_type_instance = AdditionalPropertiesAnyType.from_json(json)
# print the JSON string representation of the object
print AdditionalPropertiesAnyType.to_json()
# convert the object into a dict
additional_properties_any_type_dict = additional_properties_any_type_instance.to_dict()
# create an instance of AdditionalPropertiesAnyType from a dict
additional_properties_any_type_form_dict = additional_properties_any_type.from_dict(additional_properties_any_type_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -38,6 +38,8 @@ from petstore_api.exceptions import ApiException
from petstore_api.signing import HttpSigningConfiguration from petstore_api.signing import HttpSigningConfiguration
# import models into sdk package # import models into sdk package
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
from petstore_api.models.animal import Animal from petstore_api.models.animal import Animal

View File

@ -14,6 +14,8 @@
# import models into model package # import models into model package
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject
from petstore_api.models.additional_properties_class import AdditionalPropertiesClass from petstore_api.models.additional_properties_class import AdditionalPropertiesClass
from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef
from petstore_api.models.animal import Animal from petstore_api.models.animal import Animal

View File

@ -0,0 +1,83 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from typing import Any, Dict, Optional
from pydantic import BaseModel, StrictStr
class AdditionalPropertieAnyType(BaseModel):
"""
AdditionalPropertieAnyType
"""
name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {}
__properties = ["name"]
class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> AdditionalPropertieAnyType:
"""Create an instance of AdditionalPropertieAnyType from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
"additional_properties"
},
exclude_none=True)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
return _dict
@classmethod
def from_dict(cls, obj: dict) -> AdditionalPropertieAnyType:
"""Create an instance of AdditionalPropertieAnyType from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return AdditionalPropertieAnyType.parse_obj(obj)
_obj = AdditionalPropertieAnyType.parse_obj({
"name": obj.get("name")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj

View File

@ -0,0 +1,83 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from typing import Any, Dict, Optional
from pydantic import BaseModel, StrictStr
class AdditionalPropertieObject(BaseModel):
"""
AdditionalPropertieObject
"""
name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {}
__properties = ["name"]
class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> AdditionalPropertieObject:
"""Create an instance of AdditionalPropertieObject from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
"additional_properties"
},
exclude_none=True)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
return _dict
@classmethod
def from_dict(cls, obj: dict) -> AdditionalPropertieObject:
"""Create an instance of AdditionalPropertieObject from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return AdditionalPropertieObject.parse_obj(obj)
_obj = AdditionalPropertieObject.parse_obj({
"name": obj.get("name")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj

View File

@ -0,0 +1,83 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from typing import Any, Dict, Optional
from pydantic import BaseModel, StrictStr
class AdditionalPropertiesAnyType(BaseModel):
"""
AdditionalPropertiesAnyType
"""
name: Optional[StrictStr] = None
additional_properties: Dict[str, Any] = {}
__properties = ["name"]
class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> AdditionalPropertiesAnyType:
"""Create an instance of AdditionalPropertiesAnyType from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
"additional_properties"
},
exclude_none=True)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
return _dict
@classmethod
def from_dict(cls, obj: dict) -> AdditionalPropertiesAnyType:
"""Create an instance of AdditionalPropertiesAnyType from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return AdditionalPropertiesAnyType.parse_obj(obj)
_obj = AdditionalPropertiesAnyType.parse_obj({
"name": obj.get("name")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj

View File

@ -38,6 +38,7 @@ class NullableClass(BaseModel):
object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None object_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None object_and_items_nullable_prop: Optional[Dict[str, Dict[str, Any]]] = None
object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None object_items_nullable: Optional[Dict[str, Dict[str, Any]]] = None
additional_properties: Dict[str, Any] = {}
__properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"] __properties = ["required_integer_prop", "integer_prop", "number_prop", "boolean_prop", "string_prop", "date_prop", "datetime_prop", "array_nullable_prop", "array_and_items_nullable_prop", "array_items_nullable", "object_nullable_prop", "object_and_items_nullable_prop", "object_items_nullable"]
class Config: class Config:
@ -62,8 +63,14 @@ class NullableClass(BaseModel):
"""Returns the dictionary representation of the model using alias""" """Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True, _dict = self.dict(by_alias=True,
exclude={ exclude={
"additional_properties"
}, },
exclude_none=True) exclude_none=True)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value
# set to None if required_integer_prop (nullable) is None # set to None if required_integer_prop (nullable) is None
# and __fields_set__ contains the field # and __fields_set__ contains the field
if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__: if self.required_integer_prop is None and "required_integer_prop" in self.__fields_set__:
@ -145,6 +152,11 @@ class NullableClass(BaseModel):
"object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"), "object_and_items_nullable_prop": obj.get("object_and_items_nullable_prop"),
"object_items_nullable": obj.get("object_items_nullable") "object_items_nullable": obj.get("object_items_nullable")
}) })
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)
return _obj return _obj

View File

@ -0,0 +1,54 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
import unittest
import datetime
import petstore_api
from petstore_api.models.additional_propertie_any_type import AdditionalPropertieAnyType # noqa: E501
from petstore_api.rest import ApiException
class TestAdditionalPropertieAnyType(unittest.TestCase):
"""AdditionalPropertieAnyType unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test AdditionalPropertieAnyType
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `AdditionalPropertieAnyType`
"""
model = petstore_api.models.additional_propertie_any_type.AdditionalPropertieAnyType() # noqa: E501
if include_optional :
return AdditionalPropertieAnyType(
name = ''
)
else :
return AdditionalPropertieAnyType(
)
"""
def testAdditionalPropertieAnyType(self):
"""Test AdditionalPropertieAnyType"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,54 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
import unittest
import datetime
import petstore_api
from petstore_api.models.additional_propertie_object import AdditionalPropertieObject # noqa: E501
from petstore_api.rest import ApiException
class TestAdditionalPropertieObject(unittest.TestCase):
"""AdditionalPropertieObject unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test AdditionalPropertieObject
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `AdditionalPropertieObject`
"""
model = petstore_api.models.additional_propertie_object.AdditionalPropertieObject() # noqa: E501
if include_optional :
return AdditionalPropertieObject(
name = ''
)
else :
return AdditionalPropertieObject(
)
"""
def testAdditionalPropertieObject(self):
"""Test AdditionalPropertieObject"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,54 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
"""
import unittest
import datetime
import petstore_api
from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType # noqa: E501
from petstore_api.rest import ApiException
class TestAdditionalPropertiesAnyType(unittest.TestCase):
"""AdditionalPropertiesAnyType unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test AdditionalPropertiesAnyType
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `AdditionalPropertiesAnyType`
"""
model = petstore_api.models.additional_properties_any_type.AdditionalPropertiesAnyType() # noqa: E501
if include_optional :
return AdditionalPropertiesAnyType(
name = ''
)
else :
return AdditionalPropertiesAnyType(
)
"""
def testAdditionalPropertiesAnyType(self):
"""Test AdditionalPropertiesAnyType"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -513,3 +513,13 @@ class ModelTests(unittest.TestCase):
a = petstore_api.FirstRef.from_dict({}) a = petstore_api.FirstRef.from_dict({})
self.assertEqual(a.to_json(), "{}") self.assertEqual(a.to_json(), "{}")
def test_additional_properties(self):
a1 = petstore_api.AdditionalPropertieAnyType()
a1.additional_properties = { "abc": 123 }
self.assertEqual(a1.to_dict(), {"abc": 123})
self.assertEqual(a1.to_json(), "{\"abc\": 123}")
a2 = petstore_api.AdditionalPropertieObject()
a2.additional_properties = { "efg": 45.6 }
self.assertEqual(a2.to_dict(), {"efg": 45.6})
self.assertEqual(a2.to_json(), "{\"efg\": 45.6}")