diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java index 6c2842fec4c..b1fd059befa 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenModel.java @@ -149,7 +149,10 @@ public class CodegenModel implements IJsonSchemaValidationProperties { public String additionalPropertiesType; /** - * True if additionalProperties is set to true (boolean value) + * True if additionalProperties is set to true (boolean value), any type, free form object, etc + * + * TODO: we may rename this to isAdditionalPropertiesEnabled or something + * else to avoid confusions */ public boolean isAdditionalPropertiesTrue; @@ -1088,6 +1091,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties { Objects.equals(externalDocumentation, that.externalDocumentation) && Objects.equals(vendorExtensions, that.vendorExtensions) && Objects.equals(additionalPropertiesType, that.additionalPropertiesType) && + Objects.equals(isAdditionalPropertiesTrue, that.isAdditionalPropertiesTrue) && Objects.equals(getMaxProperties(), that.getMaxProperties()) && Objects.equals(getMinProperties(), that.getMinProperties()) && Objects.equals(getMaxItems(), that.getMaxItems()) && @@ -1193,6 +1197,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties { sb.append(", externalDocumentation=").append(externalDocumentation); sb.append(", vendorExtensions=").append(vendorExtensions); sb.append(", additionalPropertiesType='").append(additionalPropertiesType).append('\''); + sb.append(", isAdditionalPropertiesTrue='").append(isAdditionalPropertiesTrue).append('\''); sb.append(", maxProperties=").append(maxProperties); sb.append(", minProperties=").append(minProperties); sb.append(", uniqueItems=").append(uniqueItems); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 082f378c695..be13495b759 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -3179,6 +3179,9 @@ public class DefaultCodegen implements CodegenConfig { // if we are trying to set additionalProperties on an empty schema stop recursing return; } + // Note: This flag is set to true if additioanl properties + // is set (any type, free form object, boolean true, string, etc). + // The variable name may be renamed later to avoid confusion. boolean additionalPropertiesIsAnyType = false; CodegenModel m = null; if (property instanceof CodegenModel) { @@ -3199,15 +3202,14 @@ public class DefaultCodegen implements CodegenConfig { additionalPropertiesIsAnyType = true; } } else { + // if additioanl properties is set (e.g. free form object, any type, string, etc) addPropProp = fromProperty(getAdditionalPropertiesName(), (Schema) schema.getAdditionalProperties(), false); - if (ModelUtils.isAnyType((Schema) schema.getAdditionalProperties())) { - additionalPropertiesIsAnyType = true; - } + additionalPropertiesIsAnyType = true; } if (additionalPropertiesIsAnyType) { property.setAdditionalPropertiesIsAnyType(true); } - if (m != null && isAdditionalPropertiesTrue) { + if (m != null && (isAdditionalPropertiesTrue || additionalPropertiesIsAnyType)) { m.isAdditionalPropertiesTrue = true; } if (ModelUtils.isComposedSchema(schema) && !supportsAdditionalPropertiesWithComposedSchema) { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java index df6069002d4..c5c960b62d5 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java @@ -2616,7 +2616,7 @@ public class DefaultCodegenTest { cm = codegen.fromModel(modelName, sc); CodegenProperty stringCp = codegen.fromProperty("additional_properties", new Schema().type("string")); assertEquals(cm.getAdditionalProperties(), stringCp); - assertFalse(cm.getAdditionalPropertiesIsAnyType()); + assertTrue(cm.getAdditionalPropertiesIsAnyType()); } @Test @@ -2656,7 +2656,7 @@ public class DefaultCodegenTest { assertFalse(mapWithAddPropsFalse.getAdditionalPropertiesIsAnyType()); mapWithAddPropsSchema = cm.getVars().get(3); assertEquals(mapWithAddPropsSchema.getAdditionalProperties(), stringCp); - assertFalse(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); + assertTrue(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); modelName = "ObjectModelWithAddPropsInProps"; sc = openAPI.getComponents().getSchemas().get(modelName); @@ -2672,7 +2672,7 @@ public class DefaultCodegenTest { assertFalse(mapWithAddPropsFalse.getAdditionalPropertiesIsAnyType()); mapWithAddPropsSchema = cm.getVars().get(3); assertEquals(mapWithAddPropsSchema.getAdditionalProperties(), stringCp); - assertFalse(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); + assertTrue(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); if (isGenerateAliasAsModel) { // restore the setting GlobalSettings.setProperty("generateAliasAsModel", "true"); @@ -2717,7 +2717,7 @@ public class DefaultCodegenTest { assertFalse(mapWithAddPropsFalse.getAdditionalPropertiesIsAnyType()); mapWithAddPropsSchema = co.queryParams.get(3); assertEquals(mapWithAddPropsSchema.getAdditionalProperties(), stringCp); - assertFalse(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); + assertTrue(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); path = "/additional_properties/"; operation = openAPI.getPaths().get(path).getPost(); @@ -2733,7 +2733,7 @@ public class DefaultCodegenTest { assertFalse(mapWithAddPropsFalse.getAdditionalPropertiesIsAnyType()); mapWithAddPropsSchema = co.queryParams.get(3); assertEquals(mapWithAddPropsSchema.getAdditionalProperties(), stringCp); - assertFalse(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); + assertTrue(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); if (isGenerateAliasAsModel) { // restore the setting GlobalSettings.setProperty("generateAliasAsModel", "true"); @@ -2778,7 +2778,7 @@ public class DefaultCodegenTest { assertFalse(mapWithAddPropsFalse.getAdditionalPropertiesIsAnyType()); mapWithAddPropsSchema = co.responses.get(3); assertEquals(mapWithAddPropsSchema.getAdditionalProperties(), stringCp); - assertFalse(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); + assertTrue(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); path = "/additional_properties/"; operation = openAPI.getPaths().get(path).getPost(); @@ -2794,7 +2794,7 @@ public class DefaultCodegenTest { assertFalse(mapWithAddPropsFalse.getAdditionalPropertiesIsAnyType()); mapWithAddPropsSchema = co.responses.get(3); assertEquals(mapWithAddPropsSchema.getAdditionalProperties(), stringCp); - assertFalse(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); + assertTrue(mapWithAddPropsSchema.getAdditionalPropertiesIsAnyType()); if (isGenerateAliasAsModel) { // restore the setting GlobalSettings.setProperty("generateAliasAsModel", "true"); diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml index 4b16bbcff1c..85fa9290074 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml @@ -2272,4 +2272,23 @@ components: properties: skill: type: string - + AdditionalPropertiesObject: + type: object + properties: + name: + type: string + additionalProperties: + type: object + AdditionalPropertiesAnyType: + type: object + properties: + name: + type: string + additionalProperties: {} + AdditionalPropertiesWithDescriptionOnly: + type: object + properties: + name: + type: string + additionalProperties: + description: This is what the additional property is diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs index bc7147733ee..13e9311fab6 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/Drawing.cs @@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model { this._flagShapes = true; } + this.AdditionalProperties = new Dictionary(); } /// @@ -159,6 +160,12 @@ namespace Org.OpenAPITools.Model { return _flagShapes; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -172,6 +179,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -230,6 +238,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableClass.cs index 0262e604be0..b05622141cc 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/NullableClass.cs @@ -109,6 +109,7 @@ namespace Org.OpenAPITools.Model { this._flagObjectItemsNullable = true; } + this.AdditionalProperties = new Dictionary(); } /// @@ -400,6 +401,12 @@ namespace Org.OpenAPITools.Model { return _flagObjectItemsNullable; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -421,6 +428,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -511,6 +519,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs index a8bd88c42c4..9152566699e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Drawing.cs @@ -73,6 +73,12 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("shapeOrNull")] public ShapeOrNull? ShapeOrNull { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + /// /// Returns the string presentation of the object /// @@ -86,6 +92,7 @@ namespace Org.OpenAPITools.Model sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs index 8ccc53f4246..feb89d9a8dd 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs @@ -137,6 +137,12 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("string_prop")] public string? StringProp { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + /// /// Returns the string presentation of the object /// @@ -158,6 +164,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs index 8fbe4cb9b34..034136979b5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Drawing.cs @@ -71,6 +71,12 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("shapeOrNull")] public ShapeOrNull ShapeOrNull { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + /// /// Returns the string presentation of the object /// @@ -84,6 +90,7 @@ namespace Org.OpenAPITools.Model sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs index 12a1e85138d..fabf2a09c33 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -135,6 +135,12 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("string_prop")] public string StringProp { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + /// /// Returns the string presentation of the object /// @@ -156,6 +162,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs index 8fbe4cb9b34..034136979b5 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Drawing.cs @@ -71,6 +71,12 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("shapeOrNull")] public ShapeOrNull ShapeOrNull { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + /// /// Returns the string presentation of the object /// @@ -84,6 +90,7 @@ namespace Org.OpenAPITools.Model sb.Append(" Shapes: ").Append(Shapes).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs index 12a1e85138d..fabf2a09c33 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -135,6 +135,12 @@ namespace Org.OpenAPITools.Model [JsonPropertyName("string_prop")] public string StringProp { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + /// /// Returns the string presentation of the object /// @@ -156,6 +162,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" StringProp: ").Append(StringProp).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs index c5585ec01cf..f533b3bfc2e 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/Drawing.cs @@ -46,6 +46,7 @@ namespace Org.OpenAPITools.Model this.ShapeOrNull = shapeOrNull; this.NullableShape = nullableShape; this.Shapes = shapes; + this.AdditionalProperties = new Dictionary(); } /// @@ -72,6 +73,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "shapes", EmitDefaultValue = false)] public List Shapes { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -85,6 +92,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -143,6 +151,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs index ea40c1bba00..9f936ccbd88 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/NullableClass.cs @@ -62,6 +62,7 @@ namespace Org.OpenAPITools.Model this.ObjectNullableProp = objectNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectItemsNullable = objectItemsNullable; + this.AdditionalProperties = new Dictionary(); } /// @@ -137,6 +138,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] public Dictionary ObjectItemsNullable { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -158,6 +165,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -248,6 +256,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Drawing.cs index 1713fb3cfb5..d5d633ed3b3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/Drawing.cs @@ -45,6 +45,7 @@ namespace Org.OpenAPITools.Model this.ShapeOrNull = shapeOrNull; this.NullableShape = nullableShape; this.Shapes = shapes; + this.AdditionalProperties = new Dictionary(); } /// @@ -71,6 +72,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "shapes", EmitDefaultValue = false)] public List Shapes { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -84,6 +91,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -142,6 +150,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableClass.cs index c31d0e9c15d..919ed331163 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/NullableClass.cs @@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model this.ObjectNullableProp = objectNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectItemsNullable = objectItemsNullable; + this.AdditionalProperties = new Dictionary(); } /// @@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] public Dictionary ObjectItemsNullable { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Drawing.cs index 1713fb3cfb5..d5d633ed3b3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/Drawing.cs @@ -45,6 +45,7 @@ namespace Org.OpenAPITools.Model this.ShapeOrNull = shapeOrNull; this.NullableShape = nullableShape; this.Shapes = shapes; + this.AdditionalProperties = new Dictionary(); } /// @@ -71,6 +72,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "shapes", EmitDefaultValue = false)] public List Shapes { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -84,6 +91,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -142,6 +150,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableClass.cs index c31d0e9c15d..919ed331163 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/NullableClass.cs @@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model this.ObjectNullableProp = objectNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectItemsNullable = objectItemsNullable; + this.AdditionalProperties = new Dictionary(); } /// @@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] public Dictionary ObjectItemsNullable { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Drawing.cs index 1713fb3cfb5..d5d633ed3b3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/Drawing.cs @@ -45,6 +45,7 @@ namespace Org.OpenAPITools.Model this.ShapeOrNull = shapeOrNull; this.NullableShape = nullableShape; this.Shapes = shapes; + this.AdditionalProperties = new Dictionary(); } /// @@ -71,6 +72,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "shapes", EmitDefaultValue = false)] public List Shapes { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -84,6 +91,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -142,6 +150,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableClass.cs index c31d0e9c15d..919ed331163 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model this.ObjectNullableProp = objectNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectItemsNullable = objectItemsNullable; + this.AdditionalProperties = new Dictionary(); } /// @@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] public Dictionary ObjectItemsNullable { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Drawing.cs index 0d19d8d09ed..9bfd0ce588d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/Drawing.cs @@ -43,6 +43,7 @@ namespace Org.OpenAPITools.Model this.ShapeOrNull = shapeOrNull; this.NullableShape = nullableShape; this.Shapes = shapes; + this.AdditionalProperties = new Dictionary(); } /// @@ -69,6 +70,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "shapes", EmitDefaultValue = false)] public List Shapes { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -82,6 +89,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -137,7 +145,8 @@ namespace Org.OpenAPITools.Model this.Shapes != null && input.Shapes != null && this.Shapes.SequenceEqual(input.Shapes) - ); + ) + && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); } /// @@ -165,6 +174,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableClass.cs index a6c79e5460a..699f0c7881d 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/NullableClass.cs @@ -59,6 +59,7 @@ namespace Org.OpenAPITools.Model this.ObjectNullableProp = objectNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectItemsNullable = objectItemsNullable; + this.AdditionalProperties = new Dictionary(); } /// @@ -134,6 +135,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] public Dictionary ObjectItemsNullable { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -155,6 +162,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -255,7 +263,8 @@ namespace Org.OpenAPITools.Model this.ObjectItemsNullable != null && input.ObjectItemsNullable != null && this.ObjectItemsNullable.SequenceEqual(input.ObjectItemsNullable) - ); + ) + && (this.AdditionalProperties.Count == input.AdditionalProperties.Count && !this.AdditionalProperties.Except(input.AdditionalProperties).Any()); } /// @@ -315,6 +324,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Drawing.cs index 1713fb3cfb5..d5d633ed3b3 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Drawing.cs @@ -45,6 +45,7 @@ namespace Org.OpenAPITools.Model this.ShapeOrNull = shapeOrNull; this.NullableShape = nullableShape; this.Shapes = shapes; + this.AdditionalProperties = new Dictionary(); } /// @@ -71,6 +72,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "shapes", EmitDefaultValue = false)] public List Shapes { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -84,6 +91,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -142,6 +150,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableClass.cs index c31d0e9c15d..919ed331163 100644 --- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/NullableClass.cs @@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model this.ObjectNullableProp = objectNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectItemsNullable = objectItemsNullable; + this.AdditionalProperties = new Dictionary(); } /// @@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] public Dictionary ObjectItemsNullable { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Drawing.cs index 1713fb3cfb5..d5d633ed3b3 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Drawing.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/Drawing.cs @@ -45,6 +45,7 @@ namespace Org.OpenAPITools.Model this.ShapeOrNull = shapeOrNull; this.NullableShape = nullableShape; this.Shapes = shapes; + this.AdditionalProperties = new Dictionary(); } /// @@ -71,6 +72,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "shapes", EmitDefaultValue = false)] public List Shapes { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -84,6 +91,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ShapeOrNull: ").Append(ShapeOrNull).Append("\n"); sb.Append(" NullableShape: ").Append(NullableShape).Append("\n"); sb.Append(" Shapes: ").Append(Shapes).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -142,6 +150,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.Shapes.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableClass.cs index c31d0e9c15d..919ed331163 100644 --- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/NullableClass.cs @@ -61,6 +61,7 @@ namespace Org.OpenAPITools.Model this.ObjectNullableProp = objectNullableProp; this.ObjectAndItemsNullableProp = objectAndItemsNullableProp; this.ObjectItemsNullable = objectItemsNullable; + this.AdditionalProperties = new Dictionary(); } /// @@ -136,6 +137,12 @@ namespace Org.OpenAPITools.Model [DataMember(Name = "object_items_nullable", EmitDefaultValue = false)] public Dictionary ObjectItemsNullable { get; set; } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + /// /// Returns the string presentation of the object /// @@ -157,6 +164,7 @@ namespace Org.OpenAPITools.Model sb.Append(" ObjectNullableProp: ").Append(ObjectNullableProp).Append("\n"); sb.Append(" ObjectAndItemsNullableProp: ").Append(ObjectAndItemsNullableProp).Append("\n"); sb.Append(" ObjectItemsNullable: ").Append(ObjectItemsNullable).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -247,6 +255,10 @@ namespace Org.OpenAPITools.Model { hashCode = (hashCode * 59) + this.ObjectItemsNullable.GetHashCode(); } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } return hashCode; } } diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go index 9fd12d021ba..eadf2a95994 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_any_type.go @@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesAnyType{} // AdditionalPropertiesAnyType struct for AdditionalPropertiesAnyType type AdditionalPropertiesAnyType struct { Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} } +type _AdditionalPropertiesAnyType AdditionalPropertiesAnyType + // NewAdditionalPropertiesAnyType instantiates a new AdditionalPropertiesAnyType object // 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 @@ -84,9 +87,31 @@ func (o AdditionalPropertiesAnyType) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + 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 { value *AdditionalPropertiesAnyType isSet bool diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go index 9cbb26fec0d..f2527113454 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_array.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_array.go @@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesArray{} // AdditionalPropertiesArray struct for AdditionalPropertiesArray type AdditionalPropertiesArray struct { Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} } +type _AdditionalPropertiesArray AdditionalPropertiesArray + // NewAdditionalPropertiesArray instantiates a new AdditionalPropertiesArray object // 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 @@ -84,9 +87,31 @@ func (o AdditionalPropertiesArray) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return toSerialize, nil } +func (o *AdditionalPropertiesArray) UnmarshalJSON(bytes []byte) (err error) { + varAdditionalPropertiesArray := _AdditionalPropertiesArray{} + + if err = json.Unmarshal(bytes, &varAdditionalPropertiesArray); err == nil { + *o = AdditionalPropertiesArray(varAdditionalPropertiesArray) + } + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + o.AdditionalProperties = additionalProperties + } + + return err +} + type NullableAdditionalPropertiesArray struct { value *AdditionalPropertiesArray isSet bool diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go index 5659b277e6d..c1401d92912 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_boolean.go @@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesBoolean{} // AdditionalPropertiesBoolean struct for AdditionalPropertiesBoolean type AdditionalPropertiesBoolean struct { Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} } +type _AdditionalPropertiesBoolean AdditionalPropertiesBoolean + // NewAdditionalPropertiesBoolean instantiates a new AdditionalPropertiesBoolean object // 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 @@ -84,9 +87,31 @@ func (o AdditionalPropertiesBoolean) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return toSerialize, nil } +func (o *AdditionalPropertiesBoolean) UnmarshalJSON(bytes []byte) (err error) { + varAdditionalPropertiesBoolean := _AdditionalPropertiesBoolean{} + + if err = json.Unmarshal(bytes, &varAdditionalPropertiesBoolean); err == nil { + *o = AdditionalPropertiesBoolean(varAdditionalPropertiesBoolean) + } + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + o.AdditionalProperties = additionalProperties + } + + return err +} + type NullableAdditionalPropertiesBoolean struct { value *AdditionalPropertiesBoolean isSet bool diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go index 9873644fe54..0147d6eaf85 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_integer.go @@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesInteger{} // AdditionalPropertiesInteger struct for AdditionalPropertiesInteger type AdditionalPropertiesInteger struct { Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} } +type _AdditionalPropertiesInteger AdditionalPropertiesInteger + // NewAdditionalPropertiesInteger instantiates a new AdditionalPropertiesInteger object // 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 @@ -84,9 +87,31 @@ func (o AdditionalPropertiesInteger) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return toSerialize, nil } +func (o *AdditionalPropertiesInteger) UnmarshalJSON(bytes []byte) (err error) { + varAdditionalPropertiesInteger := _AdditionalPropertiesInteger{} + + if err = json.Unmarshal(bytes, &varAdditionalPropertiesInteger); err == nil { + *o = AdditionalPropertiesInteger(varAdditionalPropertiesInteger) + } + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + o.AdditionalProperties = additionalProperties + } + + return err +} + type NullableAdditionalPropertiesInteger struct { value *AdditionalPropertiesInteger isSet bool diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go index a1cb5187a5b..85b3663bf4c 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_number.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_number.go @@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesNumber{} // AdditionalPropertiesNumber struct for AdditionalPropertiesNumber type AdditionalPropertiesNumber struct { Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} } +type _AdditionalPropertiesNumber AdditionalPropertiesNumber + // NewAdditionalPropertiesNumber instantiates a new AdditionalPropertiesNumber object // 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 @@ -84,9 +87,31 @@ func (o AdditionalPropertiesNumber) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return toSerialize, nil } +func (o *AdditionalPropertiesNumber) UnmarshalJSON(bytes []byte) (err error) { + varAdditionalPropertiesNumber := _AdditionalPropertiesNumber{} + + if err = json.Unmarshal(bytes, &varAdditionalPropertiesNumber); err == nil { + *o = AdditionalPropertiesNumber(varAdditionalPropertiesNumber) + } + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + o.AdditionalProperties = additionalProperties + } + + return err +} + type NullableAdditionalPropertiesNumber struct { value *AdditionalPropertiesNumber isSet bool diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go index 201a624e05d..7132cbe61bc 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_object.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_object.go @@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesObject{} // AdditionalPropertiesObject struct for AdditionalPropertiesObject type AdditionalPropertiesObject struct { Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} } +type _AdditionalPropertiesObject AdditionalPropertiesObject + // NewAdditionalPropertiesObject instantiates a new AdditionalPropertiesObject object // 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 @@ -84,9 +87,31 @@ func (o AdditionalPropertiesObject) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + 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 { value *AdditionalPropertiesObject isSet bool diff --git a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go index df649a265a1..70882312adf 100644 --- a/samples/client/petstore/go/go-petstore/model_additional_properties_string.go +++ b/samples/client/petstore/go/go-petstore/model_additional_properties_string.go @@ -20,8 +20,11 @@ var _ MappedNullable = &AdditionalPropertiesString{} // AdditionalPropertiesString struct for AdditionalPropertiesString type AdditionalPropertiesString struct { Name *string `json:"name,omitempty"` + AdditionalProperties map[string]interface{} } +type _AdditionalPropertiesString AdditionalPropertiesString + // NewAdditionalPropertiesString instantiates a new AdditionalPropertiesString object // 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 @@ -84,9 +87,31 @@ func (o AdditionalPropertiesString) ToMap() (map[string]interface{}, error) { if !IsNil(o.Name) { toSerialize["name"] = o.Name } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return toSerialize, nil } +func (o *AdditionalPropertiesString) UnmarshalJSON(bytes []byte) (err error) { + varAdditionalPropertiesString := _AdditionalPropertiesString{} + + if err = json.Unmarshal(bytes, &varAdditionalPropertiesString); err == nil { + *o = AdditionalPropertiesString(varAdditionalPropertiesString) + } + + additionalProperties := make(map[string]interface{}) + + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + delete(additionalProperties, "name") + o.AdditionalProperties = additionalProperties + } + + return err +} + type NullableAdditionalPropertiesString struct { value *AdditionalPropertiesString isSet bool diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java index 38302f996d3..255661a6849 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java @@ -79,6 +79,50 @@ public class AdditionalPropertiesAnyType { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map 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(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +134,13 @@ public class AdditionalPropertiesAnyType { return false; } AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; - return Objects.equals(this.name, additionalPropertiesAnyType.name); + return Objects.equals(this.name, additionalPropertiesAnyType.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesAnyType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -103,6 +148,7 @@ public class AdditionalPropertiesAnyType { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesAnyType {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -143,14 +189,6 @@ public class AdditionalPropertiesAnyType { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesAnyType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -172,6 +210,23 @@ public class AdditionalPropertiesAnyType { @Override public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +234,28 @@ public class AdditionalPropertiesAnyType { public AdditionalPropertiesAnyType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesAnyType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java index 5252f9e9f37..91767c706f4 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java @@ -80,6 +80,50 @@ public class AdditionalPropertiesArray { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesArray instance itself + */ + public AdditionalPropertiesArray putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -91,12 +135,13 @@ public class AdditionalPropertiesArray { return false; } AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; - return Objects.equals(this.name, additionalPropertiesArray.name); + return Objects.equals(this.name, additionalPropertiesArray.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesArray.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -104,6 +149,7 @@ public class AdditionalPropertiesArray { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesArray {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -144,14 +190,6 @@ public class AdditionalPropertiesArray { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesArray.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -173,6 +211,23 @@ public class AdditionalPropertiesArray { @Override public void write(JsonWriter out, AdditionalPropertiesArray value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -180,7 +235,28 @@ public class AdditionalPropertiesArray { public AdditionalPropertiesArray read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesArray instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java index 0ab06c7e54d..803574cfa6a 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java @@ -79,6 +79,50 @@ public class AdditionalPropertiesBoolean { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesBoolean instance itself + */ + public AdditionalPropertiesBoolean putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +134,13 @@ public class AdditionalPropertiesBoolean { return false; } AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; - return Objects.equals(this.name, additionalPropertiesBoolean.name); + return Objects.equals(this.name, additionalPropertiesBoolean.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesBoolean.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -103,6 +148,7 @@ public class AdditionalPropertiesBoolean { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesBoolean {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -143,14 +189,6 @@ public class AdditionalPropertiesBoolean { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesBoolean.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -172,6 +210,23 @@ public class AdditionalPropertiesBoolean { @Override public void write(JsonWriter out, AdditionalPropertiesBoolean value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +234,28 @@ public class AdditionalPropertiesBoolean { public AdditionalPropertiesBoolean read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesBoolean instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java index 92c9ca7cc50..f07e09810b0 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java @@ -79,6 +79,50 @@ public class AdditionalPropertiesInteger { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesInteger instance itself + */ + public AdditionalPropertiesInteger putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +134,13 @@ public class AdditionalPropertiesInteger { return false; } AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; - return Objects.equals(this.name, additionalPropertiesInteger.name); + return Objects.equals(this.name, additionalPropertiesInteger.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesInteger.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -103,6 +148,7 @@ public class AdditionalPropertiesInteger { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesInteger {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -143,14 +189,6 @@ public class AdditionalPropertiesInteger { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesInteger.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -172,6 +210,23 @@ public class AdditionalPropertiesInteger { @Override public void write(JsonWriter out, AdditionalPropertiesInteger value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +234,28 @@ public class AdditionalPropertiesInteger { public AdditionalPropertiesInteger read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesInteger instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java index f786790043b..02fe36ad974 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java @@ -80,6 +80,50 @@ public class AdditionalPropertiesNumber { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesNumber instance itself + */ + public AdditionalPropertiesNumber putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -91,12 +135,13 @@ public class AdditionalPropertiesNumber { return false; } AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; - return Objects.equals(this.name, additionalPropertiesNumber.name); + return Objects.equals(this.name, additionalPropertiesNumber.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesNumber.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -104,6 +149,7 @@ public class AdditionalPropertiesNumber { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesNumber {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -144,14 +190,6 @@ public class AdditionalPropertiesNumber { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesNumber.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -173,6 +211,23 @@ public class AdditionalPropertiesNumber { @Override public void write(JsonWriter out, AdditionalPropertiesNumber value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -180,7 +235,28 @@ public class AdditionalPropertiesNumber { public AdditionalPropertiesNumber read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesNumber instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java index 8d7686e9800..6e7968267bd 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java @@ -80,6 +80,50 @@ public class AdditionalPropertiesObject { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map 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(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -91,12 +135,13 @@ public class AdditionalPropertiesObject { return false; } AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; - return Objects.equals(this.name, additionalPropertiesObject.name); + return Objects.equals(this.name, additionalPropertiesObject.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesObject.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -104,6 +149,7 @@ public class AdditionalPropertiesObject { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesObject {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -144,14 +190,6 @@ public class AdditionalPropertiesObject { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesObject.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -173,6 +211,23 @@ public class AdditionalPropertiesObject { @Override public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -180,7 +235,28 @@ public class AdditionalPropertiesObject { public AdditionalPropertiesObject read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesObject instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java index 6dae21f945b..e957ecab147 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java @@ -79,6 +79,50 @@ public class AdditionalPropertiesString { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesString instance itself + */ + public AdditionalPropertiesString putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -90,12 +134,13 @@ public class AdditionalPropertiesString { return false; } AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; - return Objects.equals(this.name, additionalPropertiesString.name); + return Objects.equals(this.name, additionalPropertiesString.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesString.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -103,6 +148,7 @@ public class AdditionalPropertiesString { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesString {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -143,14 +189,6 @@ public class AdditionalPropertiesString { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesString.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -172,6 +210,23 @@ public class AdditionalPropertiesString { @Override public void write(JsonWriter out, AdditionalPropertiesString value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -179,7 +234,28 @@ public class AdditionalPropertiesString { public AdditionalPropertiesString read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesString instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java index 8d642af57bf..b93480b42e1 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesAnyType.java @@ -81,6 +81,50 @@ public class AdditionalPropertiesAnyType implements Parcelable { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map 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(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -92,12 +136,13 @@ public class AdditionalPropertiesAnyType implements Parcelable { return false; } AdditionalPropertiesAnyType additionalPropertiesAnyType = (AdditionalPropertiesAnyType) o; - return Objects.equals(this.name, additionalPropertiesAnyType.name); + return Objects.equals(this.name, additionalPropertiesAnyType.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesAnyType.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -105,6 +150,7 @@ public class AdditionalPropertiesAnyType implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesAnyType {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,14 +212,6 @@ public class AdditionalPropertiesAnyType implements Parcelable { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesAnyType is not found in the empty JSON string", AdditionalPropertiesAnyType.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesAnyType.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesAnyType` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -195,6 +233,23 @@ public class AdditionalPropertiesAnyType implements Parcelable { @Override public void write(JsonWriter out, AdditionalPropertiesAnyType value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -202,7 +257,28 @@ public class AdditionalPropertiesAnyType implements Parcelable { public AdditionalPropertiesAnyType read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesAnyType instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java index fe46853e434..a54c96aa592 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesArray.java @@ -82,6 +82,50 @@ public class AdditionalPropertiesArray implements Parcelable { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesArray instance itself + */ + public AdditionalPropertiesArray putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -93,12 +137,13 @@ public class AdditionalPropertiesArray implements Parcelable { return false; } AdditionalPropertiesArray additionalPropertiesArray = (AdditionalPropertiesArray) o; - return Objects.equals(this.name, additionalPropertiesArray.name); + return Objects.equals(this.name, additionalPropertiesArray.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesArray.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -106,6 +151,7 @@ public class AdditionalPropertiesArray implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesArray {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public class AdditionalPropertiesArray implements Parcelable { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesArray is not found in the empty JSON string", AdditionalPropertiesArray.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesArray.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesArray` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -196,6 +234,23 @@ public class AdditionalPropertiesArray implements Parcelable { @Override public void write(JsonWriter out, AdditionalPropertiesArray value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -203,7 +258,28 @@ public class AdditionalPropertiesArray implements Parcelable { public AdditionalPropertiesArray read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesArray instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java index aa666774ec5..ea9c2dafd33 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesBoolean.java @@ -81,6 +81,50 @@ public class AdditionalPropertiesBoolean implements Parcelable { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesBoolean instance itself + */ + public AdditionalPropertiesBoolean putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -92,12 +136,13 @@ public class AdditionalPropertiesBoolean implements Parcelable { return false; } AdditionalPropertiesBoolean additionalPropertiesBoolean = (AdditionalPropertiesBoolean) o; - return Objects.equals(this.name, additionalPropertiesBoolean.name); + return Objects.equals(this.name, additionalPropertiesBoolean.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesBoolean.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -105,6 +150,7 @@ public class AdditionalPropertiesBoolean implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesBoolean {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,14 +212,6 @@ public class AdditionalPropertiesBoolean implements Parcelable { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesBoolean is not found in the empty JSON string", AdditionalPropertiesBoolean.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesBoolean.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesBoolean` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -195,6 +233,23 @@ public class AdditionalPropertiesBoolean implements Parcelable { @Override public void write(JsonWriter out, AdditionalPropertiesBoolean value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -202,7 +257,28 @@ public class AdditionalPropertiesBoolean implements Parcelable { public AdditionalPropertiesBoolean read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesBoolean instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java index 590b21a6a18..2c66d554057 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesInteger.java @@ -81,6 +81,50 @@ public class AdditionalPropertiesInteger implements Parcelable { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesInteger instance itself + */ + public AdditionalPropertiesInteger putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -92,12 +136,13 @@ public class AdditionalPropertiesInteger implements Parcelable { return false; } AdditionalPropertiesInteger additionalPropertiesInteger = (AdditionalPropertiesInteger) o; - return Objects.equals(this.name, additionalPropertiesInteger.name); + return Objects.equals(this.name, additionalPropertiesInteger.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesInteger.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -105,6 +150,7 @@ public class AdditionalPropertiesInteger implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesInteger {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,14 +212,6 @@ public class AdditionalPropertiesInteger implements Parcelable { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesInteger is not found in the empty JSON string", AdditionalPropertiesInteger.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesInteger.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesInteger` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -195,6 +233,23 @@ public class AdditionalPropertiesInteger implements Parcelable { @Override public void write(JsonWriter out, AdditionalPropertiesInteger value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -202,7 +257,28 @@ public class AdditionalPropertiesInteger implements Parcelable { public AdditionalPropertiesInteger read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesInteger instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java index 95c0c465ad8..2da59e9905e 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesNumber.java @@ -82,6 +82,50 @@ public class AdditionalPropertiesNumber implements Parcelable { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesNumber instance itself + */ + public AdditionalPropertiesNumber putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -93,12 +137,13 @@ public class AdditionalPropertiesNumber implements Parcelable { return false; } AdditionalPropertiesNumber additionalPropertiesNumber = (AdditionalPropertiesNumber) o; - return Objects.equals(this.name, additionalPropertiesNumber.name); + return Objects.equals(this.name, additionalPropertiesNumber.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesNumber.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -106,6 +151,7 @@ public class AdditionalPropertiesNumber implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesNumber {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public class AdditionalPropertiesNumber implements Parcelable { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesNumber is not found in the empty JSON string", AdditionalPropertiesNumber.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesNumber.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesNumber` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -196,6 +234,23 @@ public class AdditionalPropertiesNumber implements Parcelable { @Override public void write(JsonWriter out, AdditionalPropertiesNumber value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -203,7 +258,28 @@ public class AdditionalPropertiesNumber implements Parcelable { public AdditionalPropertiesNumber read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesNumber instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java index d6179b5e062..57483da3767 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesObject.java @@ -82,6 +82,50 @@ public class AdditionalPropertiesObject implements Parcelable { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map 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(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -93,12 +137,13 @@ public class AdditionalPropertiesObject implements Parcelable { return false; } AdditionalPropertiesObject additionalPropertiesObject = (AdditionalPropertiesObject) o; - return Objects.equals(this.name, additionalPropertiesObject.name); + return Objects.equals(this.name, additionalPropertiesObject.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesObject.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -106,6 +151,7 @@ public class AdditionalPropertiesObject implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesObject {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -167,14 +213,6 @@ public class AdditionalPropertiesObject implements Parcelable { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesObject is not found in the empty JSON string", AdditionalPropertiesObject.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesObject.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesObject` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -196,6 +234,23 @@ public class AdditionalPropertiesObject implements Parcelable { @Override public void write(JsonWriter out, AdditionalPropertiesObject value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -203,7 +258,28 @@ public class AdditionalPropertiesObject implements Parcelable { public AdditionalPropertiesObject read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesObject instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java index a01f05e1b2b..c0ce3d56ba2 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/model/AdditionalPropertiesString.java @@ -81,6 +81,50 @@ public class AdditionalPropertiesString implements Parcelable { this.name = name; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the AdditionalPropertiesString instance itself + */ + public AdditionalPropertiesString putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -92,12 +136,13 @@ public class AdditionalPropertiesString implements Parcelable { return false; } AdditionalPropertiesString additionalPropertiesString = (AdditionalPropertiesString) o; - return Objects.equals(this.name, additionalPropertiesString.name); + return Objects.equals(this.name, additionalPropertiesString.name)&& + Objects.equals(this.additionalProperties, additionalPropertiesString.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -105,6 +150,7 @@ public class AdditionalPropertiesString implements Parcelable { StringBuilder sb = new StringBuilder(); sb.append("class AdditionalPropertiesString {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -166,14 +212,6 @@ public class AdditionalPropertiesString implements Parcelable { throw new IllegalArgumentException(String.format("The required field(s) %s in AdditionalPropertiesString is not found in the empty JSON string", AdditionalPropertiesString.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!AdditionalPropertiesString.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `AdditionalPropertiesString` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); @@ -195,6 +233,23 @@ public class AdditionalPropertiesString implements Parcelable { @Override public void write(JsonWriter out, AdditionalPropertiesString value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -202,7 +257,28 @@ public class AdditionalPropertiesString implements Parcelable { public AdditionalPropertiesString read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AdditionalPropertiesString instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Drawing.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Drawing.java index ea738037f86..2c4b7eff572 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Drawing.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/Drawing.java @@ -169,6 +169,50 @@ public class Drawing { this.shapes = shapes; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Drawing instance itself + */ + public Drawing putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -183,7 +227,8 @@ public class Drawing { return Objects.equals(this.mainShape, drawing.mainShape) && Objects.equals(this.shapeOrNull, drawing.shapeOrNull) && Objects.equals(this.nullableShape, drawing.nullableShape) && - Objects.equals(this.shapes, drawing.shapes); + Objects.equals(this.shapes, drawing.shapes)&& + Objects.equals(this.additionalProperties, drawing.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -192,7 +237,7 @@ public class Drawing { @Override public int hashCode() { - return Objects.hash(mainShape, shapeOrNull, nullableShape, shapes); + return Objects.hash(mainShape, shapeOrNull, nullableShape, shapes, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -210,6 +255,7 @@ public class Drawing { sb.append(" shapeOrNull: ").append(toIndentedString(shapeOrNull)).append("\n"); sb.append(" nullableShape: ").append(toIndentedString(nullableShape)).append("\n"); sb.append(" shapes: ").append(toIndentedString(shapes)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -253,14 +299,6 @@ public class Drawing { throw new IllegalArgumentException(String.format("The required field(s) %s in Drawing is not found in the empty JSON string", Drawing.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Drawing.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Drawing` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `mainShape` if (jsonObj.get("mainShape") != null && !jsonObj.get("mainShape").isJsonNull()) { @@ -305,6 +343,23 @@ public class Drawing { @Override public void write(JsonWriter out, Drawing value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -312,7 +367,28 @@ public class Drawing { public Drawing read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Drawing instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NullableClass.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NullableClass.java index a6b7762819d..8c2e799566d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NullableClass.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/model/NullableClass.java @@ -410,6 +410,50 @@ public class NullableClass { this.objectItemsNullable = objectItemsNullable; } + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map 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(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } @Override @@ -432,7 +476,8 @@ public class NullableClass { Objects.equals(this.arrayItemsNullable, nullableClass.arrayItemsNullable) && Objects.equals(this.objectNullableProp, nullableClass.objectNullableProp) && Objects.equals(this.objectAndItemsNullableProp, nullableClass.objectAndItemsNullableProp) && - Objects.equals(this.objectItemsNullable, nullableClass.objectItemsNullable); + Objects.equals(this.objectItemsNullable, nullableClass.objectItemsNullable)&& + Objects.equals(this.additionalProperties, nullableClass.additionalProperties); } private static boolean equalsNullable(JsonNullable a, JsonNullable b) { @@ -441,7 +486,7 @@ public class NullableClass { @Override public int hashCode() { - return Objects.hash(integerProp, numberProp, booleanProp, stringProp, dateProp, datetimeProp, arrayNullableProp, arrayAndItemsNullableProp, arrayItemsNullable, objectNullableProp, objectAndItemsNullableProp, objectItemsNullable); + return Objects.hash(integerProp, numberProp, booleanProp, stringProp, dateProp, datetimeProp, arrayNullableProp, arrayAndItemsNullableProp, arrayItemsNullable, objectNullableProp, objectAndItemsNullableProp, objectItemsNullable, additionalProperties); } private static int hashCodeNullable(JsonNullable a) { @@ -467,6 +512,7 @@ public class NullableClass { sb.append(" objectNullableProp: ").append(toIndentedString(objectNullableProp)).append("\n"); sb.append(" objectAndItemsNullableProp: ").append(toIndentedString(objectAndItemsNullableProp)).append("\n"); sb.append(" objectItemsNullable: ").append(toIndentedString(objectItemsNullable)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); sb.append("}"); return sb.toString(); } @@ -518,14 +564,6 @@ public class NullableClass { throw new IllegalArgumentException(String.format("The required field(s) %s in NullableClass is not found in the empty JSON string", NullableClass.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!NullableClass.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NullableClass` properties. JSON: %s", entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("string_prop") != null && !jsonObj.get("string_prop").isJsonNull()) && !jsonObj.get("string_prop").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `string_prop` to be a primitive type in the JSON string but got `%s`", jsonObj.get("string_prop").toString())); @@ -559,6 +597,23 @@ public class NullableClass { @Override public void write(JsonWriter out, NullableClass value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } elementAdapter.write(out, obj); } @@ -566,7 +621,28 @@ public class NullableClass { public NullableClass read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + NullableClass instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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(); diff --git a/samples/client/petstore/powershell/src/PSPetstore/Model/Drawing.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Model/Drawing.ps1 index 3db24f69486..853e8b0b9a3 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Model/Drawing.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Model/Drawing.ps1 @@ -89,12 +89,14 @@ function ConvertFrom-PSJsonToDrawing { $PSBoundParameters | Out-DebugParameter | Write-Debug $JsonParameters = ConvertFrom-Json -InputObject $Json + $PSDrawingAdditionalProperties = @{} # check if Json contains properties not defined in PSDrawing $AllProperties = ("mainShape", "shapeOrNull", "nullableShape", "shapes") foreach ($name in $JsonParameters.PsObject.Properties.Name) { + # store undefined properties in additionalProperties if (!($AllProperties.Contains($name))) { - throw "Error! JSON key '$name' not found in the properties: $($AllProperties)" + $PSDrawingAdditionalProperties[$name] = $JsonParameters.PSobject.Properties[$name].value } } @@ -127,6 +129,7 @@ function ConvertFrom-PSJsonToDrawing { "shapeOrNull" = ${ShapeOrNull} "nullableShape" = ${NullableShape} "shapes" = ${Shapes} + "AdditionalProperties" = $PSDrawingAdditionalProperties } return $PSO diff --git a/samples/client/petstore/powershell/src/PSPetstore/Model/NullableClass.ps1 b/samples/client/petstore/powershell/src/PSPetstore/Model/NullableClass.ps1 index 21755910978..07dd0d94b71 100644 --- a/samples/client/petstore/powershell/src/PSPetstore/Model/NullableClass.ps1 +++ b/samples/client/petstore/powershell/src/PSPetstore/Model/NullableClass.ps1 @@ -137,12 +137,14 @@ function ConvertFrom-PSJsonToNullableClass { $PSBoundParameters | Out-DebugParameter | Write-Debug $JsonParameters = ConvertFrom-Json -InputObject $Json + $PSNullableClassAdditionalProperties = @{} # 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") foreach ($name in $JsonParameters.PsObject.Properties.Name) { + # store undefined properties in additionalProperties 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_and_items_nullable_prop" = ${ObjectAndItemsNullableProp} "object_items_nullable" = ${ObjectItemsNullable} + "AdditionalProperties" = $PSNullableClassAdditionalProperties } return $PSO diff --git a/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts b/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts index dddf833bbb6..9a75bfa1ab1 100644 --- a/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts +++ b/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts @@ -447,7 +447,7 @@ export interface Dog extends Animal { * @interface Drawing */ export interface Drawing { - [key: string]: Fruit | any; + [key: string]: Fruit; /** * @@ -1043,7 +1043,7 @@ export interface Name { * @interface NullableClass */ export interface NullableClass { - [key: string]: object | any; + [key: string]: object; /** * diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts index fbb65d70790..e4d6dc1e4db 100644 --- a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts @@ -811,7 +811,7 @@ export interface Name { * @interface NullableClass */ export interface NullableClass { - [key: string]: object | any; + [key: string]: object; /** * diff --git a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go index 0c173346d22..580936cff21 100644 --- a/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go +++ b/samples/openapi3/client/petstore/go/go-petstore/model_nullable_class.go @@ -32,8 +32,11 @@ type NullableClass struct { ObjectNullableProp map[string]map[string]interface{} `json:"object_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"` + AdditionalProperties map[string]interface{} } +type _NullableClass NullableClass + // NewNullableClass instantiates a new NullableClass object // 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 @@ -549,9 +552,42 @@ func (o NullableClass) ToMap() (map[string]interface{}, error) { if !IsNil(o.ObjectItemsNullable) { toSerialize["object_items_nullable"] = o.ObjectItemsNullable } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + 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 { value *NullableClass isSet bool diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index a30ce812a9a..7781fa1c1ed 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -3,7 +3,10 @@ .gitlab-ci.yml .travis.yml README.md +docs/AdditionalPropertiesAnyType.md docs/AdditionalPropertiesClass.md +docs/AdditionalPropertiesObject.md +docs/AdditionalPropertiesWithDescriptionOnly.md docs/AllOfWithSingleRef.md docs/Animal.md docs/AnotherFakeApi.md @@ -100,7 +103,10 @@ petstore_api/api_response.py petstore_api/configuration.py petstore_api/exceptions.py petstore_api/models/__init__.py +petstore_api/models/additional_properties_any_type.py petstore_api/models/additional_properties_class.py +petstore_api/models/additional_properties_object.py +petstore_api/models/additional_properties_with_description_only.py petstore_api/models/all_of_with_single_ref.py petstore_api/models/animal.py petstore_api/models/any_of_color.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index a443818bd2f..1c4f209dc5a 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -132,7 +132,10 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md) - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md) + - [AdditionalPropertiesWithDescriptionOnly](docs/AdditionalPropertiesWithDescriptionOnly.md) - [AllOfWithSingleRef](docs/AllOfWithSingleRef.md) - [Animal](docs/Animal.md) - [AnyOfColor](docs/AnyOfColor.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesAnyType.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesAnyType.md new file mode 100644 index 00000000000..beedef76c05 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesAnyType.md @@ -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) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesObject.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesObject.md new file mode 100644 index 00000000000..8b9259c687f --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesObject.md @@ -0,0 +1,28 @@ +# AdditionalPropertiesObject + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesObject from a JSON string +additional_properties_object_instance = AdditionalPropertiesObject.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesObject.to_json() + +# convert the object into a dict +additional_properties_object_dict = additional_properties_object_instance.to_dict() +# create an instance of AdditionalPropertiesObject from a dict +additional_properties_object_form_dict = additional_properties_object.from_dict(additional_properties_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) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesWithDescriptionOnly.md b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesWithDescriptionOnly.md new file mode 100644 index 00000000000..d66094f18e5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/AdditionalPropertiesWithDescriptionOnly.md @@ -0,0 +1,28 @@ +# AdditionalPropertiesWithDescriptionOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string +additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesWithDescriptionOnly.to_json() + +# convert the object into a dict +additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.to_dict() +# create an instance of AdditionalPropertiesWithDescriptionOnly from a dict +additional_properties_with_description_only_form_dict = additional_properties_with_description_only.from_dict(additional_properties_with_description_only_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) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py index 65b7d10c97b..477c4bf2443 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -38,7 +38,10 @@ from petstore_api.exceptions import ApiException from petstore_api.signing import HttpSigningConfiguration # import models into sdk package +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType from petstore_api.models.additional_properties_class import AdditionalPropertiesClass +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py index 144361528d0..3f90e0e18fd 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py @@ -14,7 +14,10 @@ # import models into model package +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType from petstore_api.models.additional_properties_class import AdditionalPropertiesClass +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py new file mode 100644 index 00000000000..025b73438c8 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_any_type.py @@ -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 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 + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py new file mode 100644 index 00000000000..f554b782f70 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_object.py @@ -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 AdditionalPropertiesObject(BaseModel): + """ + AdditionalPropertiesObject + """ + 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) -> AdditionalPropertiesObject: + """Create an instance of AdditionalPropertiesObject 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) -> AdditionalPropertiesObject: + """Create an instance of AdditionalPropertiesObject from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesObject.parse_obj(obj) + + _obj = AdditionalPropertiesObject.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 + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py new file mode 100644 index 00000000000..a21bb9571f6 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/additional_properties_with_description_only.py @@ -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 AdditionalPropertiesWithDescriptionOnly(BaseModel): + """ + AdditionalPropertiesWithDescriptionOnly + """ + 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) -> AdditionalPropertiesWithDescriptionOnly: + """Create an instance of AdditionalPropertiesWithDescriptionOnly 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) -> AdditionalPropertiesWithDescriptionOnly: + """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesWithDescriptionOnly.parse_obj(obj) + + _obj = AdditionalPropertiesWithDescriptionOnly.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 + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py index d1ca0e060c1..42a110d479e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/nullable_class.py @@ -38,6 +38,7 @@ class NullableClass(BaseModel): object_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 + 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"] class Config: @@ -62,8 +63,14 @@ class NullableClass(BaseModel): """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 + # set to None if required_integer_prop (nullable) is None # and __fields_set__ contains the field 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_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 diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_any_type.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_any_type.py new file mode 100644 index 00000000000..c2c9c7c5806 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_any_type.py @@ -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() diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_class.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_class.py index 77df2fe73c5..e3b48bedd57 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_class.py @@ -6,12 +6,12 @@ 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: https://openapi-generator.tech + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. """ -from __future__ import absolute_import - import unittest import datetime @@ -33,7 +33,9 @@ class TestAdditionalPropertiesClass(unittest.TestCase): include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = petstore_api.models.additional_properties_class.AdditionalPropertiesClass() # noqa: E501 + # uncomment below to create an instance of `AdditionalPropertiesClass` + """ + model = petstore_api.models.additional_properties_class.AdditionalPropertiesClass() # noqa: E501 if include_optional : return AdditionalPropertiesClass( map_property = { @@ -48,6 +50,7 @@ class TestAdditionalPropertiesClass(unittest.TestCase): else : return AdditionalPropertiesClass( ) + """ def testAdditionalPropertiesClass(self): """Test AdditionalPropertiesClass""" diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_object.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_object.py new file mode 100644 index 00000000000..b68a8fda579 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_object.py @@ -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_object import AdditionalPropertiesObject # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesObject(unittest.TestCase): + """AdditionalPropertiesObject unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesObject + 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 `AdditionalPropertiesObject` + """ + model = petstore_api.models.additional_properties_object.AdditionalPropertiesObject() # noqa: E501 + if include_optional : + return AdditionalPropertiesObject( + name = '' + ) + else : + return AdditionalPropertiesObject( + ) + """ + + def testAdditionalPropertiesObject(self): + """Test AdditionalPropertiesObject""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_with_description_only.py new file mode 100644 index 00000000000..d5166dfe134 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_additional_properties_with_description_only.py @@ -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_with_description_only import AdditionalPropertiesWithDescriptionOnly # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesWithDescriptionOnly(unittest.TestCase): + """AdditionalPropertiesWithDescriptionOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesWithDescriptionOnly + 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 `AdditionalPropertiesWithDescriptionOnly` + """ + model = petstore_api.models.additional_properties_with_description_only.AdditionalPropertiesWithDescriptionOnly() # noqa: E501 + if include_optional : + return AdditionalPropertiesWithDescriptionOnly( + name = '' + ) + else : + return AdditionalPropertiesWithDescriptionOnly( + ) + """ + + def testAdditionalPropertiesWithDescriptionOnly(self): + """Test AdditionalPropertiesWithDescriptionOnly""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index 370c0480ea2..fdd09778983 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -3,7 +3,10 @@ .gitlab-ci.yml .travis.yml README.md +docs/AdditionalPropertiesAnyType.md docs/AdditionalPropertiesClass.md +docs/AdditionalPropertiesObject.md +docs/AdditionalPropertiesWithDescriptionOnly.md docs/AllOfWithSingleRef.md docs/Animal.md docs/AnotherFakeApi.md @@ -100,7 +103,10 @@ petstore_api/api_response.py petstore_api/configuration.py petstore_api/exceptions.py petstore_api/models/__init__.py +petstore_api/models/additional_properties_any_type.py petstore_api/models/additional_properties_class.py +petstore_api/models/additional_properties_object.py +petstore_api/models/additional_properties_with_description_only.py petstore_api/models/all_of_with_single_ref.py petstore_api/models/animal.py petstore_api/models/any_of_color.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 534b6c8135a..e99d03b1d80 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -132,7 +132,10 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md) - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md) + - [AdditionalPropertiesWithDescriptionOnly](docs/AdditionalPropertiesWithDescriptionOnly.md) - [AllOfWithSingleRef](docs/AllOfWithSingleRef.md) - [Animal](docs/Animal.md) - [AnyOfColor](docs/AnyOfColor.md) diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesAnyType.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesAnyType.md new file mode 100644 index 00000000000..beedef76c05 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesAnyType.md @@ -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) + + diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesClass.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesObject.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesObject.md new file mode 100644 index 00000000000..8b9259c687f --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesObject.md @@ -0,0 +1,28 @@ +# AdditionalPropertiesObject + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesObject from a JSON string +additional_properties_object_instance = AdditionalPropertiesObject.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesObject.to_json() + +# convert the object into a dict +additional_properties_object_dict = additional_properties_object_instance.to_dict() +# create an instance of AdditionalPropertiesObject from a dict +additional_properties_object_form_dict = additional_properties_object.from_dict(additional_properties_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) + + diff --git a/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithDescriptionOnly.md b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithDescriptionOnly.md new file mode 100644 index 00000000000..d66094f18e5 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/AdditionalPropertiesWithDescriptionOnly.md @@ -0,0 +1,28 @@ +# AdditionalPropertiesWithDescriptionOnly + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly + +# TODO update the JSON string below +json = "{}" +# create an instance of AdditionalPropertiesWithDescriptionOnly from a JSON string +additional_properties_with_description_only_instance = AdditionalPropertiesWithDescriptionOnly.from_json(json) +# print the JSON string representation of the object +print AdditionalPropertiesWithDescriptionOnly.to_json() + +# convert the object into a dict +additional_properties_with_description_only_dict = additional_properties_with_description_only_instance.to_dict() +# create an instance of AdditionalPropertiesWithDescriptionOnly from a dict +additional_properties_with_description_only_form_dict = additional_properties_with_description_only.from_dict(additional_properties_with_description_only_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) + + diff --git a/samples/openapi3/client/petstore/python/docs/Animal.md b/samples/openapi3/client/petstore/python/docs/Animal.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/AnotherFakeApi.md b/samples/openapi3/client/petstore/python/docs/AnotherFakeApi.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/ApiResponse.md b/samples/openapi3/client/petstore/python/docs/ApiResponse.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python/docs/ArrayOfArrayOfNumberOnly.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md b/samples/openapi3/client/petstore/python/docs/ArrayOfNumberOnly.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/ArrayTest.md b/samples/openapi3/client/petstore/python/docs/ArrayTest.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Capitalization.md b/samples/openapi3/client/petstore/python/docs/Capitalization.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Cat.md b/samples/openapi3/client/petstore/python/docs/Cat.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Category.md b/samples/openapi3/client/petstore/python/docs/Category.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/ClassModel.md b/samples/openapi3/client/petstore/python/docs/ClassModel.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Client.md b/samples/openapi3/client/petstore/python/docs/Client.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/DefaultApi.md b/samples/openapi3/client/petstore/python/docs/DefaultApi.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Dog.md b/samples/openapi3/client/petstore/python/docs/Dog.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/EnumArrays.md b/samples/openapi3/client/petstore/python/docs/EnumArrays.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/EnumClass.md b/samples/openapi3/client/petstore/python/docs/EnumClass.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/EnumTest.md b/samples/openapi3/client/petstore/python/docs/EnumTest.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/FakeApi.md b/samples/openapi3/client/petstore/python/docs/FakeApi.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/python/docs/FakeClassnameTags123Api.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/File.md b/samples/openapi3/client/petstore/python/docs/File.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md b/samples/openapi3/client/petstore/python/docs/FileSchemaTestClass.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Foo.md b/samples/openapi3/client/petstore/python/docs/Foo.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/FormatTest.md b/samples/openapi3/client/petstore/python/docs/FormatTest.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md b/samples/openapi3/client/petstore/python/docs/HasOnlyReadOnly.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md b/samples/openapi3/client/petstore/python/docs/HealthCheckResult.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject.md b/samples/openapi3/client/petstore/python/docs/InlineObject.md deleted file mode 100755 index f567ea188ce..00000000000 --- a/samples/openapi3/client/petstore/python/docs/InlineObject.md +++ /dev/null @@ -1,11 +0,0 @@ -# InlineObject - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **str** | Updated name of the pet | [optional] -**status** | **str** | Updated status of the pet | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject1.md b/samples/openapi3/client/petstore/python/docs/InlineObject1.md deleted file mode 100755 index 42d38efa301..00000000000 --- a/samples/openapi3/client/petstore/python/docs/InlineObject1.md +++ /dev/null @@ -1,11 +0,0 @@ -# InlineObject1 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**additional_metadata** | **str** | Additional data to pass to server | [optional] -**file** | **file** | file to upload | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject2.md b/samples/openapi3/client/petstore/python/docs/InlineObject2.md deleted file mode 100755 index 9bfba12f6f1..00000000000 --- a/samples/openapi3/client/petstore/python/docs/InlineObject2.md +++ /dev/null @@ -1,11 +0,0 @@ -# InlineObject2 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**enum_form_string_array** | **list[str]** | Form parameter enum test (string array) | [optional] -**enum_form_string** | **str** | Form parameter enum test (string) | [optional] [default to '-efg'] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject3.md b/samples/openapi3/client/petstore/python/docs/InlineObject3.md deleted file mode 100755 index ef9845fcd9c..00000000000 --- a/samples/openapi3/client/petstore/python/docs/InlineObject3.md +++ /dev/null @@ -1,23 +0,0 @@ -# InlineObject3 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**integer** | **int** | None | [optional] -**int32** | **int** | None | [optional] -**int64** | **int** | None | [optional] -**number** | **float** | None | -**float** | **float** | None | [optional] -**double** | **float** | None | -**string** | **str** | None | [optional] -**pattern_without_delimiter** | **str** | None | -**byte** | **str** | None | -**binary** | **file** | None | [optional] -**date** | **date** | None | [optional] -**date_time** | **datetime** | None | [optional] -**password** | **str** | None | [optional] -**callback** | **str** | None | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject4.md b/samples/openapi3/client/petstore/python/docs/InlineObject4.md deleted file mode 100755 index 07574d0d076..00000000000 --- a/samples/openapi3/client/petstore/python/docs/InlineObject4.md +++ /dev/null @@ -1,11 +0,0 @@ -# InlineObject4 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**param** | **str** | field1 | -**param2** | **str** | field2 | - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/InlineObject5.md b/samples/openapi3/client/petstore/python/docs/InlineObject5.md deleted file mode 100755 index c4502f70f9c..00000000000 --- a/samples/openapi3/client/petstore/python/docs/InlineObject5.md +++ /dev/null @@ -1,11 +0,0 @@ -# InlineObject5 - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**additional_metadata** | **str** | Additional data to pass to server | [optional] -**required_file** | **file** | file to upload | - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/InlineResponseDefault.md b/samples/openapi3/client/petstore/python/docs/InlineResponseDefault.md deleted file mode 100755 index f0a52bc4639..00000000000 --- a/samples/openapi3/client/petstore/python/docs/InlineResponseDefault.md +++ /dev/null @@ -1,11 +0,0 @@ -# InlineResponseDefault - - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**string** | [**Foo**](Foo.md) | | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/List.md b/samples/openapi3/client/petstore/python/docs/List.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/MapTest.md b/samples/openapi3/client/petstore/python/docs/MapTest.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Model200Response.md b/samples/openapi3/client/petstore/python/docs/Model200Response.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/ModelReturn.md b/samples/openapi3/client/petstore/python/docs/ModelReturn.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Model_200Response.md b/samples/openapi3/client/petstore/python/docs/Model_200Response.md deleted file mode 100644 index 4fd119d1251..00000000000 --- a/samples/openapi3/client/petstore/python/docs/Model_200Response.md +++ /dev/null @@ -1,13 +0,0 @@ -# Model_200Response - -Model for testing model name starting with number - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **int** | | [optional] -**_class** | **str** | | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/Model_Return.md b/samples/openapi3/client/petstore/python/docs/Model_Return.md deleted file mode 100644 index 674c441551b..00000000000 --- a/samples/openapi3/client/petstore/python/docs/Model_Return.md +++ /dev/null @@ -1,12 +0,0 @@ -# Model_Return - -Model for testing reserved words - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**_return** | **int** | | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/Name.md b/samples/openapi3/client/petstore/python/docs/Name.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/NestedOneOf.md b/samples/openapi3/client/petstore/python/docs/NestedOneOf.md deleted file mode 100644 index 913192432e7..00000000000 --- a/samples/openapi3/client/petstore/python/docs/NestedOneOf.md +++ /dev/null @@ -1,12 +0,0 @@ -# NestedOneOf - - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**size** | **int** | | [optional] -**nested_pig** | [**Pig**](Pig.md) | | [optional] - -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/samples/openapi3/client/petstore/python/docs/NullableClass.md b/samples/openapi3/client/petstore/python/docs/NullableClass.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/NumberOnly.md b/samples/openapi3/client/petstore/python/docs/NumberOnly.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Order.md b/samples/openapi3/client/petstore/python/docs/Order.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/OuterComposite.md b/samples/openapi3/client/petstore/python/docs/OuterComposite.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/OuterEnum.md b/samples/openapi3/client/petstore/python/docs/OuterEnum.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/OuterEnumDefaultValue.md b/samples/openapi3/client/petstore/python/docs/OuterEnumDefaultValue.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/OuterEnumInteger.md b/samples/openapi3/client/petstore/python/docs/OuterEnumInteger.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/OuterEnumIntegerDefaultValue.md b/samples/openapi3/client/petstore/python/docs/OuterEnumIntegerDefaultValue.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Pet.md b/samples/openapi3/client/petstore/python/docs/Pet.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/PetApi.md b/samples/openapi3/client/petstore/python/docs/PetApi.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md b/samples/openapi3/client/petstore/python/docs/ReadOnlyFirst.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/SpecialModelName.md b/samples/openapi3/client/petstore/python/docs/SpecialModelName.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/StoreApi.md b/samples/openapi3/client/petstore/python/docs/StoreApi.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/Tag.md b/samples/openapi3/client/petstore/python/docs/Tag.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/User.md b/samples/openapi3/client/petstore/python/docs/User.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/docs/UserApi.md b/samples/openapi3/client/petstore/python/docs/UserApi.md old mode 100755 new mode 100644 diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index 65b7d10c97b..477c4bf2443 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -38,7 +38,10 @@ from petstore_api.exceptions import ApiException from petstore_api.signing import HttpSigningConfiguration # import models into sdk package +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType from petstore_api.models.additional_properties_class import AdditionalPropertiesClass +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index 144361528d0..3f90e0e18fd 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -14,7 +14,10 @@ # import models into model package +from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType from petstore_api.models.additional_properties_class import AdditionalPropertiesClass +from petstore_api.models.additional_properties_object import AdditionalPropertiesObject +from petstore_api.models.additional_properties_with_description_only import AdditionalPropertiesWithDescriptionOnly from petstore_api.models.all_of_with_single_ref import AllOfWithSingleRef from petstore_api.models.animal import Animal from petstore_api.models.any_of_color import AnyOfColor diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py new file mode 100644 index 00000000000..3b6407e160d --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_any_type.py @@ -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 + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py new file mode 100644 index 00000000000..dc372c7d86b --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_object.py @@ -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 AdditionalPropertiesObject(BaseModel): + """ + AdditionalPropertiesObject + """ + 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) -> AdditionalPropertiesObject: + """Create an instance of AdditionalPropertiesObject 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) -> AdditionalPropertiesObject: + """Create an instance of AdditionalPropertiesObject from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesObject.parse_obj(obj) + + _obj = AdditionalPropertiesObject.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 + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py new file mode 100644 index 00000000000..eb9ac44cae8 --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/additional_properties_with_description_only.py @@ -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 AdditionalPropertiesWithDescriptionOnly(BaseModel): + """ + AdditionalPropertiesWithDescriptionOnly + """ + 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) -> AdditionalPropertiesWithDescriptionOnly: + """Create an instance of AdditionalPropertiesWithDescriptionOnly 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) -> AdditionalPropertiesWithDescriptionOnly: + """Create an instance of AdditionalPropertiesWithDescriptionOnly from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return AdditionalPropertiesWithDescriptionOnly.parse_obj(obj) + + _obj = AdditionalPropertiesWithDescriptionOnly.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 + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py index cfd086598f3..01343f9d82a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/nullable_class.py @@ -38,6 +38,7 @@ class NullableClass(BaseModel): object_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 + 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"] class Config: @@ -62,8 +63,14 @@ class NullableClass(BaseModel): """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 + # set to None if required_integer_prop (nullable) is None # and __fields_set__ contains the field 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_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 diff --git a/samples/openapi3/client/petstore/python/test/test_additional_properties_any_type.py b/samples/openapi3/client/petstore/python/test/test_additional_properties_any_type.py new file mode 100644 index 00000000000..c2c9c7c5806 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_additional_properties_any_type.py @@ -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() diff --git a/samples/openapi3/client/petstore/python/test/test_additional_properties_class.py b/samples/openapi3/client/petstore/python/test/test_additional_properties_class.py index 4383ae1726b..e3b48bedd57 100644 --- a/samples/openapi3/client/petstore/python/test/test_additional_properties_class.py +++ b/samples/openapi3/client/petstore/python/test/test_additional_properties_class.py @@ -6,12 +6,12 @@ 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: https://openapi-generator.tech + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. """ -from __future__ import absolute_import - import unittest import datetime @@ -33,7 +33,9 @@ class TestAdditionalPropertiesClass(unittest.TestCase): include_option is a boolean, when False only required params are included, when True both required and optional params are included """ - # model = petstore_api.models.additional_properties_class.AdditionalPropertiesClass() # noqa: E501 + # uncomment below to create an instance of `AdditionalPropertiesClass` + """ + model = petstore_api.models.additional_properties_class.AdditionalPropertiesClass() # noqa: E501 if include_optional : return AdditionalPropertiesClass( map_property = { @@ -48,11 +50,12 @@ class TestAdditionalPropertiesClass(unittest.TestCase): else : return AdditionalPropertiesClass( ) + """ def testAdditionalPropertiesClass(self): """Test AdditionalPropertiesClass""" - inst_req_only = self.make_instance(include_optional=False) - inst_req_and_optional = self.make_instance(include_optional=True) + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) if __name__ == '__main__': unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_additional_properties_object.py b/samples/openapi3/client/petstore/python/test/test_additional_properties_object.py new file mode 100644 index 00000000000..b68a8fda579 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_additional_properties_object.py @@ -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_object import AdditionalPropertiesObject # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesObject(unittest.TestCase): + """AdditionalPropertiesObject unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesObject + 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 `AdditionalPropertiesObject` + """ + model = petstore_api.models.additional_properties_object.AdditionalPropertiesObject() # noqa: E501 + if include_optional : + return AdditionalPropertiesObject( + name = '' + ) + else : + return AdditionalPropertiesObject( + ) + """ + + def testAdditionalPropertiesObject(self): + """Test AdditionalPropertiesObject""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_additional_properties_with_description_only.py b/samples/openapi3/client/petstore/python/test/test_additional_properties_with_description_only.py new file mode 100644 index 00000000000..d5166dfe134 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_additional_properties_with_description_only.py @@ -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_with_description_only import AdditionalPropertiesWithDescriptionOnly # noqa: E501 +from petstore_api.rest import ApiException + +class TestAdditionalPropertiesWithDescriptionOnly(unittest.TestCase): + """AdditionalPropertiesWithDescriptionOnly unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test AdditionalPropertiesWithDescriptionOnly + 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 `AdditionalPropertiesWithDescriptionOnly` + """ + model = petstore_api.models.additional_properties_with_description_only.AdditionalPropertiesWithDescriptionOnly() # noqa: E501 + if include_optional : + return AdditionalPropertiesWithDescriptionOnly( + name = '' + ) + else : + return AdditionalPropertiesWithDescriptionOnly( + ) + """ + + def testAdditionalPropertiesWithDescriptionOnly(self): + """Test AdditionalPropertiesWithDescriptionOnly""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests/test_model.py b/samples/openapi3/client/petstore/python/tests/test_model.py index 7032ed8893e..01d5d001fab 100644 --- a/samples/openapi3/client/petstore/python/tests/test_model.py +++ b/samples/openapi3/client/petstore/python/tests/test_model.py @@ -519,4 +519,18 @@ class ModelTests(unittest.TestCase): # shouldn't throw NameError self.assertEqual(model.to_json(), '{"skill": "none", "type": "tiger", "info": {"name": "creature info"}}') + def test_additional_properties(self): + a1 = petstore_api.AdditionalPropertiesAnyType() + a1.additional_properties = { "abc": 123 } + self.assertEqual(a1.to_dict(), {"abc": 123}) + self.assertEqual(a1.to_json(), "{\"abc\": 123}") + a2 = petstore_api.AdditionalPropertiesObject() + a2.additional_properties = { "efg": 45.6 } + self.assertEqual(a2.to_dict(), {"efg": 45.6}) + self.assertEqual(a2.to_json(), "{\"efg\": 45.6}") + + a3 = petstore_api.AdditionalPropertiesWithDescriptionOnly() + a3.additional_properties = { "xyz": 45.6 } + self.assertEqual(a3.to_dict(), {"xyz": 45.6}) + self.assertEqual(a3.to_json(), "{\"xyz\": 45.6}")