diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache index b5d2e170157e..1405dd77c79d 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache @@ -51,7 +51,7 @@ {{/-first}} if (discriminator != null && discriminator.Equals("{{name}}")) - return JsonSerializer.Deserialize<{{{name}}}>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + return JsonSerializer.Deserialize<{{{classname}}}>(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); {{/children}} {{/discriminator}} @@ -348,7 +348,7 @@ {{#discriminator}} {{#children}} if ({{#lambda.paste}}{{/lambda.paste}} is {{classname}} {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}){ - JsonSerializer.Serialize<{{{name}}}>(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions); + JsonSerializer.Serialize<{{{classname}}}>(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}, jsonSerializerOptions); return; } diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 8980bb997e43..b2c1365f903c 100644 --- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -2938,3 +2938,28 @@ components: uuid: type: string format: uuid + CopyActivity: + type: object + required: + - $schema + - copyActivitytt + properties: + $schema: + type: string + enum: + - ScopeActivity + copyActivitytt: + type: string + allOf: + - $ref: '#/components/schemas/EntityBase' + EntityBase: + type: object + required: + - $schema + properties: + $schema: + type: string + discriminator: + propertyName: $schema + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES index 45c476af3183..b9a5acbac345 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/.openapi-generator/FILES @@ -30,11 +30,13 @@ docs/models/ChildCat.md docs/models/ChildCatAllOfPetType.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumArraysArrayEnumInner.md docs/models/EnumArraysJustSymbol.md @@ -187,11 +189,13 @@ src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml index 6b2a30f1db4c..2430a21de4fd 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml @@ -2694,6 +2694,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 599ba401258a..66af4c79a0e3 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -169,6 +169,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCatAllOfPetType childCatAllOfPetType) return ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCatAllOfPetType); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArraysArrayEnumInner enumArraysArrayEnumInner) return EnumArraysArrayEnumInnerValueConverter.ToJsonValue(enumArraysArrayEnumInner); if (obj is EnumArraysJustSymbol enumArraysJustSymbol) diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs index c706302171c4..14e2fd920e83 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -60,11 +60,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatAllOfPetTypeNullableJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES index 0bf16fb19b73..80e274401fdc 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -163,11 +165,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 231c516c999c..560c039d70a9 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -169,6 +169,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs index e12f1ae97793..f4224c601f0c 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -58,11 +58,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES index 45c476af3183..b9a5acbac345 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/.openapi-generator/FILES @@ -30,11 +30,13 @@ docs/models/ChildCat.md docs/models/ChildCatAllOfPetType.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumArraysArrayEnumInner.md docs/models/EnumArraysJustSymbol.md @@ -187,11 +189,13 @@ src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml index 6b2a30f1db4c..2430a21de4fd 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/api/openapi.yaml @@ -2694,6 +2694,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 599ba401258a..66af4c79a0e3 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -169,6 +169,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCatAllOfPetType childCatAllOfPetType) return ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCatAllOfPetType); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArraysArrayEnumInner enumArraysArrayEnumInner) return EnumArraysArrayEnumInnerValueConverter.ToJsonValue(enumArraysArrayEnumInner); if (obj is EnumArraysJustSymbol enumArraysJustSymbol) diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs index c706302171c4..14e2fd920e83 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -60,11 +60,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatAllOfPetTypeNullableJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES index 0bf16fb19b73..80e274401fdc 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -163,11 +165,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 231c516c999c..560c039d70a9 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -169,6 +169,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs index e12f1ae97793..f4224c601f0c 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -58,11 +58,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES index bc72f8c05ba1..a1ef5edacd90 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES @@ -30,11 +30,13 @@ docs/models/ChildCat.md docs/models/ChildCatAllOfPetType.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumArraysArrayEnumInner.md docs/models/EnumArraysJustSymbol.md @@ -189,11 +191,13 @@ src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml index 6b2a30f1db4c..2430a21de4fd 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml @@ -2694,6 +2694,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net8/FormModels/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 32d03988e2d1..025b10ff3f0a 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -168,6 +168,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCatAllOfPetType childCatAllOfPetType) return ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCatAllOfPetType); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArraysArrayEnumInner enumArraysArrayEnumInner) return EnumArraysArrayEnumInnerValueConverter.ToJsonValue(enumArraysArrayEnumInner); if (obj is EnumArraysJustSymbol enumArraysJustSymbol) diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs index f35ca51d2d2a..a63f96c31ee9 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -62,11 +62,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatAllOfPetTypeNullableJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES index afb25a1c17e1..2c3e342eac8c 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -165,11 +167,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index ec53dbda4326..caef12016777 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -170,6 +170,8 @@ public static string SanitizeFilename(string filename) : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs index 8be0791ee4fb..240e556b9b3e 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -62,11 +62,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..6acd040dc2e8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,228 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string? schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value!); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..fa8a54d9dd01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,186 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string? discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES index afb25a1c17e1..2c3e342eac8c 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -165,11 +167,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net8/Petstore/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index b8e281efd8ba..0dfe6afc4b13 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -168,6 +168,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs index cb0e43c85272..b2246d1a538b 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -60,11 +60,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES index afb25a1c17e1..2c3e342eac8c 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -165,11 +167,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index ec53dbda4326..caef12016777 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -170,6 +170,8 @@ public static string SanitizeFilename(string filename) : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs index 03e2cd6ecb87..c7ce3c05913a 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -62,11 +62,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); @@ -169,11 +171,13 @@ public HostConfiguration(IServiceCollection services) new ChildCatSerializationContext(), new ClassModelSerializationContext(), new ComplexQuadrilateralSerializationContext(), + new CopyActivitySerializationContext(), new DanishPigSerializationContext(), new DateOnlyClassSerializationContext(), new DeprecatedObjectSerializationContext(), new DogSerializationContext(), new DrawingSerializationContext(), + new EntityBaseSerializationContext(), new EnumArraysSerializationContext(), new EnumClassSerializationContext(), new EnumTestSerializationContext(), diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..3fd719564b91 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,236 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Text.Json.Serialization.Metadata; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string? schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value!); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } + + /// + /// The CopyActivitySerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(CopyActivity))] + public partial class CopyActivitySerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..c8e883631368 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,194 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Text.Json.Serialization.Metadata; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string? discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } + + /// + /// The EntityBaseSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(EntityBase))] + public partial class EntityBaseSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES index bc72f8c05ba1..a1ef5edacd90 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES @@ -30,11 +30,13 @@ docs/models/ChildCat.md docs/models/ChildCatAllOfPetType.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumArraysArrayEnumInner.md docs/models/EnumArraysJustSymbol.md @@ -189,11 +191,13 @@ src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ChildCatAllOfPetType.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumArraysArrayEnumInner.cs src/Org.OpenAPITools/Model/EnumArraysJustSymbol.cs diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml index 6b2a30f1db4c..2430a21de4fd 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml @@ -2694,6 +2694,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net9/FormModels/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs index 32d03988e2d1..025b10ff3f0a 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -168,6 +168,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCatAllOfPetType childCatAllOfPetType) return ChildCatAllOfPetTypeValueConverter.ToJsonValue(childCatAllOfPetType); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArraysArrayEnumInner enumArraysArrayEnumInner) return EnumArraysArrayEnumInnerValueConverter.ToJsonValue(enumArraysArrayEnumInner); if (obj is EnumArraysJustSymbol enumArraysJustSymbol) diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs index f35ca51d2d2a..a63f96c31ee9 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -62,11 +62,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatAllOfPetTypeNullableJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysArrayEnumInnerNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES index afb25a1c17e1..2c3e342eac8c 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -165,11 +167,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs index ec53dbda4326..caef12016777 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -170,6 +170,8 @@ public static string SanitizeFilename(string filename) : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs index 8be0791ee4fb..240e556b9b3e 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -62,11 +62,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..6acd040dc2e8 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,228 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string? schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value!); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..fa8a54d9dd01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,186 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string? discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES index afb25a1c17e1..2c3e342eac8c 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -165,11 +167,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net9/Petstore/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index b8e281efd8ba..0dfe6afc4b13 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -168,6 +168,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs index cb0e43c85272..b2246d1a538b 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -60,11 +60,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES index afb25a1c17e1..2c3e342eac8c 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -165,11 +167,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs index ec53dbda4326..caef12016777 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -170,6 +170,8 @@ public static string SanitizeFilename(string filename) : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs index 03e2cd6ecb87..c7ce3c05913a 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -62,11 +62,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); @@ -169,11 +171,13 @@ public HostConfiguration(IServiceCollection services) new ChildCatSerializationContext(), new ClassModelSerializationContext(), new ComplexQuadrilateralSerializationContext(), + new CopyActivitySerializationContext(), new DanishPigSerializationContext(), new DateOnlyClassSerializationContext(), new DeprecatedObjectSerializationContext(), new DogSerializationContext(), new DrawingSerializationContext(), + new EntityBaseSerializationContext(), new EnumArraysSerializationContext(), new EnumClassSerializationContext(), new EnumTestSerializationContext(), diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..3fd719564b91 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,236 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Text.Json.Serialization.Metadata; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string? schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value!); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } + + /// + /// The CopyActivitySerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(CopyActivity))] + public partial class CopyActivitySerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..c8e883631368 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,194 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using System.Text.Json.Serialization.Metadata; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string? discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string? localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } + + /// + /// The EntityBaseSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(EntityBase))] + public partial class EntityBaseSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES index 0bf16fb19b73..80e274401fdc 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/.openapi-generator/FILES @@ -29,11 +29,13 @@ docs/models/Category.md docs/models/ChildCat.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md +docs/models/CopyActivity.md docs/models/DanishPig.md docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/Drawing.md +docs/models/EntityBase.md docs/models/EnumArrays.md docs/models/EnumClass.md docs/models/EnumTest.md @@ -163,11 +165,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/CopyActivity.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/CopyActivity.md new file mode 100644 index 000000000000..eb13cef5182d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**CopyActivitytt** | **string** | | +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] + +[[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/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/EntityBase.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/EntityBase.md new file mode 100644 index 000000000000..b00b029d2f0c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..fbff5039599e --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..7c7833da4fcb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs index 231c516c999c..560c039d70a9 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/ClientUtils.cs @@ -169,6 +169,8 @@ public static string ParameterToString(object obj, string format = ISO8601_DATET : "false"; if (obj is ChildCat.PetTypeEnum childCatPetTypeEnum) return ChildCat.PetTypeEnumToJsonValue(childCatPetTypeEnum); + if (obj is CopyActivity.SchemaEnum copyActivitySchemaEnum) + return CopyActivity.SchemaEnumToJsonValue(copyActivitySchemaEnum); if (obj is EnumArrays.ArrayEnumEnum enumArraysArrayEnumEnum) return EnumArrays.ArrayEnumEnumToJsonValue(enumArraysArrayEnumEnum); if (obj is EnumArrays.JustSymbolEnum enumArraysJustSymbolEnum) diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs index e12f1ae97793..f4224c601f0c 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -58,11 +58,13 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ChildCatJsonConverter()); _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); + _jsonOptions.Converters.Add(new CopyActivityJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DrawingJsonConverter()); + _jsonOptions.Converters.Add(new EntityBaseJsonConverter()); _jsonOptions.Converters.Add(new EnumArraysJsonConverter()); _jsonOptions.Converters.Add(new EnumClassJsonConverter()); _jsonOptions.Converters.Add(new EnumClassNullableJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7fbda7a016ba --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,226 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + public partial class CopyActivity : EntityBase, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// copyActivitytt + [JsonConstructor] + public CopyActivity(string copyActivitytt) : base() + { + CopyActivitytt = copyActivitytt; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Defines Schema + /// + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + ScopeActivity = 1 + } + + /// + /// Returns a + /// + /// + /// + /// + public static SchemaEnum SchemaEnumFromString(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + throw new NotImplementedException($"Could not convert value to type SchemaEnum: '{value}'"); + } + + /// + /// Returns a + /// + /// + /// + public static SchemaEnum? SchemaEnumFromStringOrDefault(string value) + { + if (value.Equals("ScopeActivity")) + return SchemaEnum.ScopeActivity; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string SchemaEnumToJsonValue(SchemaEnum value) + { + if (value == SchemaEnum.ScopeActivity) + return "ScopeActivity"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public new SchemaEnum Schema { get; } = (SchemaEnum)Enum.Parse(typeof(SchemaEnum), "CopyActivity"); + + /// + /// Gets or Sets CopyActivitytt + /// + [JsonPropertyName("copyActivitytt")] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString()?.Replace("\n", "\n ")).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + } + + /// + /// A Json converter for type + /// + public class CopyActivityJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override CopyActivity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + Option copyActivitytt = default; + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + string schemaRawValue = utf8JsonReader.GetString(); + if (schemaRawValue != null) + schema = new Option(CopyActivity.SchemaEnumFromStringOrDefault(schemaRawValue)); + break; + case "copyActivitytt": + copyActivitytt = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(schema)); + + if (!copyActivitytt.IsSet) + throw new ArgumentException("Property is required for class CopyActivity.", nameof(copyActivitytt)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class CopyActivity."); + + if (copyActivitytt.IsSet && copyActivitytt.Value == null) + throw new ArgumentNullException(nameof(copyActivitytt), "Property is not nullable for class CopyActivity."); + + return new CopyActivity(copyActivitytt.Value); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, copyActivity, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, CopyActivity copyActivity, JsonSerializerOptions jsonSerializerOptions) + { + if (copyActivity.CopyActivitytt == null) + throw new ArgumentNullException(nameof(copyActivity.CopyActivitytt), "Property is required for class CopyActivity."); + + writer.WriteString("$schema", CopyActivity.SchemaEnumToJsonValue(copyActivity.Schema)); + + writer.WriteString("copyActivitytt", copyActivity.CopyActivitytt); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..21bb6398df95 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,184 @@ +// +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + public partial class EntityBase : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructor] + public EntityBase() + { + OnCreated(); + } + + partial void OnCreated(); + + /// + /// The discriminator + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public string Schema { get; } = "EntityBase"; + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class EntityBaseJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override EntityBase Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert, JsonSerializerOptions jsonSerializerOptions) + { + int currentDepth = utf8JsonReader.CurrentDepth; + + if (utf8JsonReader.TokenType != JsonTokenType.StartObject && utf8JsonReader.TokenType != JsonTokenType.StartArray) + throw new JsonException(); + + JsonTokenType startingTokenType = utf8JsonReader.TokenType; + + Option schema = default; + + string discriminator = ClientUtils.GetDiscriminator(utf8JsonReader, "$schema"); + + if (discriminator != null && discriminator.Equals("CopyActivity")) + return JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions) ?? throw new JsonException("The result was an unexpected value."); + + while (utf8JsonReader.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReader.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReader.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReader.CurrentDepth) + break; + + if (utf8JsonReader.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReader.CurrentDepth - 1) + { + string localVarJsonPropertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (localVarJsonPropertyName) + { + case "$schema": + schema = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (!schema.IsSet) + throw new ArgumentException("Property is required for class EntityBase.", nameof(schema)); + + if (schema.IsSet && schema.Value == null) + throw new ArgumentNullException(nameof(schema), "Property is not nullable for class EntityBase."); + + return new EntityBase(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + if (entityBase is CopyActivity copyActivity){ + JsonSerializer.Serialize(writer, copyActivity, jsonSerializerOptions); + return; + } + + writer.WriteStartObject(); + + WriteProperties(writer, entityBase, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, EntityBase entityBase, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteString("$schema", entityBase.Schema); + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/httpclient/net9/Petstore/.openapi-generator/FILES index 2d32d3d7d05e..89ea02c0b61b 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/.openapi-generator/FILES @@ -23,12 +23,14 @@ docs/Category.md docs/ChildCat.md docs/ClassModel.md docs/ComplexQuadrilateral.md +docs/CopyActivity.md docs/DanishPig.md docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md docs/Drawing.md +docs/EntityBase.md docs/EnumArrays.md docs/EnumClass.md docs/EnumTest.md @@ -153,11 +155,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md index 2340534ae7c3..850a233587d1 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md @@ -213,11 +213,13 @@ Class | Method | HTTP request | Description - [Model.ChildCat](docs/ChildCat.md) - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) + - [Model.CopyActivity](docs/CopyActivity.md) - [Model.DanishPig](docs/DanishPig.md) - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.Drawing](docs/Drawing.md) + - [Model.EntityBase](docs/EntityBase.md) - [Model.EnumArrays](docs/EnumArrays.md) - [Model.EnumClass](docs/EnumClass.md) - [Model.EnumTest](docs/EnumTest.md) diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/CopyActivity.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/CopyActivity.md new file mode 100644 index 000000000000..6fe25862b72d --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**CopyActivitytt** | **string** | | + +[[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/client/petstore/csharp/httpclient/net9/Petstore/docs/EntityBase.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/EntityBase.md new file mode 100644 index 000000000000..2e4e018f7add --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..ddd13c677214 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..0178210290cd --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,76 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..caf3c2f38c3c --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,185 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + [DataContract(Name = "CopyActivity")] + public partial class CopyActivity : EntityBase, IEquatable, IValidatableObject + { + /// + /// Defines Schema + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + [EnumMember(Value = "ScopeActivity")] + ScopeActivity = 1 + } + + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public SchemaEnum Schema { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected CopyActivity() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// schema (required) (default to SchemaEnum.ScopeActivity). + /// copyActivitytt (required). + public CopyActivity(SchemaEnum schema = SchemaEnum.ScopeActivity, string copyActivitytt = default(string)) : base() + { + this.Schema = schema; + // to ensure "copyActivitytt" is required (not null) + if (copyActivitytt == null) + { + throw new ArgumentNullException("copyActivitytt is a required property for CopyActivity and cannot be null"); + } + this.CopyActivitytt = copyActivitytt; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets CopyActivitytt + /// + [DataMember(Name = "copyActivitytt", IsRequired = true, EmitDefaultValue = true)] + public string CopyActivitytt { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as CopyActivity).AreEqual; + } + + /// + /// Returns true if CopyActivity instances are equal + /// + /// Instance of CopyActivity to be compared + /// Boolean + public bool Equals(CopyActivity input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + if (this.CopyActivitytt != null) + { + hashCode = (hashCode * 59) + this.CopyActivitytt.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + foreach (var x in base.BaseValidate(validationContext)) + { + yield return x; + } + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..fd2318387c00 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,159 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + [DataContract(Name = "EntityBase")] + [JsonConverter(typeof(JsonSubtypes), "Schema")] + [JsonSubtypes.KnownSubType(typeof(CopyActivity), "ScopeActivity")] + public partial class EntityBase : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected EntityBase() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// schema (required). + public EntityBase(string schema = default(string)) + { + // to ensure "schema" is required (not null) + if (schema == null) + { + throw new ArgumentNullException("schema is a required property for EntityBase and cannot be null"); + } + this.Schema = schema; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public string Schema { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as EntityBase).AreEqual; + } + + /// + /// Returns true if EntityBase instances are equal + /// + /// Instance of EntityBase to be compared + /// Boolean + public bool Equals(EntityBase input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Schema != null) + { + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/.openapi-generator/FILES index 8ad42be271f2..571b78dd9b10 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/.openapi-generator/FILES @@ -23,12 +23,14 @@ docs/Category.md docs/ChildCat.md docs/ClassModel.md docs/ComplexQuadrilateral.md +docs/CopyActivity.md docs/DanishPig.md docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md docs/Drawing.md +docs/EntityBase.md docs/EnumArrays.md docs/EnumClass.md docs/EnumTest.md @@ -152,11 +154,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md index 36f943cd758b..5a9be2e87505 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md @@ -201,11 +201,13 @@ Class | Method | HTTP request | Description - [Model.ChildCat](docs/ChildCat.md) - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) + - [Model.CopyActivity](docs/CopyActivity.md) - [Model.DanishPig](docs/DanishPig.md) - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.Drawing](docs/Drawing.md) + - [Model.EntityBase](docs/EntityBase.md) - [Model.EnumArrays](docs/EnumArrays.md) - [Model.EnumClass](docs/EnumClass.md) - [Model.EnumTest](docs/EnumTest.md) diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/CopyActivity.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/CopyActivity.md new file mode 100644 index 000000000000..6fe25862b72d --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**CopyActivitytt** | **string** | | + +[[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/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/EntityBase.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/EntityBase.md new file mode 100644 index 000000000000..2e4e018f7add --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..ddd13c677214 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..0178210290cd --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,76 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..caf3c2f38c3c --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,185 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + [DataContract(Name = "CopyActivity")] + public partial class CopyActivity : EntityBase, IEquatable, IValidatableObject + { + /// + /// Defines Schema + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + [EnumMember(Value = "ScopeActivity")] + ScopeActivity = 1 + } + + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public SchemaEnum Schema { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected CopyActivity() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// schema (required) (default to SchemaEnum.ScopeActivity). + /// copyActivitytt (required). + public CopyActivity(SchemaEnum schema = SchemaEnum.ScopeActivity, string copyActivitytt = default(string)) : base() + { + this.Schema = schema; + // to ensure "copyActivitytt" is required (not null) + if (copyActivitytt == null) + { + throw new ArgumentNullException("copyActivitytt is a required property for CopyActivity and cannot be null"); + } + this.CopyActivitytt = copyActivitytt; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets CopyActivitytt + /// + [DataMember(Name = "copyActivitytt", IsRequired = true, EmitDefaultValue = true)] + public string CopyActivitytt { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as CopyActivity).AreEqual; + } + + /// + /// Returns true if CopyActivity instances are equal + /// + /// Instance of CopyActivity to be compared + /// Boolean + public bool Equals(CopyActivity input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + if (this.CopyActivitytt != null) + { + hashCode = (hashCode * 59) + this.CopyActivitytt.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + foreach (var x in base.BaseValidate(validationContext)) + { + yield return x; + } + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..fd2318387c00 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,159 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + [DataContract(Name = "EntityBase")] + [JsonConverter(typeof(JsonSubtypes), "Schema")] + [JsonSubtypes.KnownSubType(typeof(CopyActivity), "ScopeActivity")] + public partial class EntityBase : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected EntityBase() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// schema (required). + public EntityBase(string schema = default(string)) + { + // to ensure "schema" is required (not null) + if (schema == null) + { + throw new ArgumentNullException("schema is a required property for EntityBase and cannot be null"); + } + this.Schema = schema; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public string Schema { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as EntityBase).AreEqual; + } + + /// + /// Returns true if EntityBase instances are equal + /// + /// Instance of EntityBase to be compared + /// Boolean + public bool Equals(EntityBase input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Schema != null) + { + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/restsharp/net8/Petstore/.openapi-generator/FILES index 2a5dbfbe6e6f..05aeba36d54c 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/.openapi-generator/FILES @@ -23,12 +23,14 @@ docs/Category.md docs/ChildCat.md docs/ClassModel.md docs/ComplexQuadrilateral.md +docs/CopyActivity.md docs/DanishPig.md docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md docs/Drawing.md +docs/EntityBase.md docs/EnumArrays.md docs/EnumClass.md docs/EnumTest.md @@ -155,11 +157,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md index 1ea97fc434be..7d4a2e1b1ff4 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md @@ -188,11 +188,13 @@ Class | Method | HTTP request | Description - [Model.ChildCat](docs/ChildCat.md) - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) + - [Model.CopyActivity](docs/CopyActivity.md) - [Model.DanishPig](docs/DanishPig.md) - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.Drawing](docs/Drawing.md) + - [Model.EntityBase](docs/EntityBase.md) - [Model.EnumArrays](docs/EnumArrays.md) - [Model.EnumClass](docs/EnumClass.md) - [Model.EnumTest](docs/EnumTest.md) diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/CopyActivity.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/CopyActivity.md new file mode 100644 index 000000000000..6fe25862b72d --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**CopyActivitytt** | **string** | | + +[[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/client/petstore/csharp/restsharp/net8/Petstore/docs/EntityBase.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/EntityBase.md new file mode 100644 index 000000000000..2e4e018f7add --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..ddd13c677214 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..0178210290cd --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,76 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..8d9899c2d1ae --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,169 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + [DataContract(Name = "CopyActivity")] + public partial class CopyActivity : EntityBase, IEquatable, IValidatableObject + { + /// + /// Defines Schema + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + [EnumMember(Value = "ScopeActivity")] + ScopeActivity = 1 + } + + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public SchemaEnum Schema { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected CopyActivity() { } + /// + /// Initializes a new instance of the class. + /// + /// schema (required) (default to SchemaEnum.ScopeActivity). + /// copyActivitytt (required). + public CopyActivity(SchemaEnum schema = SchemaEnum.ScopeActivity, string copyActivitytt = default(string)) : base() + { + this.Schema = schema; + // to ensure "copyActivitytt" is required (not null) + if (copyActivitytt == null) + { + throw new ArgumentNullException("copyActivitytt is a required property for CopyActivity and cannot be null"); + } + this.CopyActivitytt = copyActivitytt; + } + + /// + /// Gets or Sets CopyActivitytt + /// + [DataMember(Name = "copyActivitytt", IsRequired = true, EmitDefaultValue = true)] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as CopyActivity).AreEqual; + } + + /// + /// Returns true if CopyActivity instances are equal + /// + /// Instance of CopyActivity to be compared + /// Boolean + public bool Equals(CopyActivity input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + if (this.CopyActivitytt != null) + { + hashCode = (hashCode * 59) + this.CopyActivitytt.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + foreach (var x in base.BaseValidate(validationContext)) + { + yield return x; + } + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..69957220682c --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,143 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + [DataContract(Name = "EntityBase")] + [JsonConverter(typeof(JsonSubtypes), "Schema")] + [JsonSubtypes.KnownSubType(typeof(CopyActivity), "ScopeActivity")] + public partial class EntityBase : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected EntityBase() { } + /// + /// Initializes a new instance of the class. + /// + /// schema (required). + public EntityBase(string schema = default(string)) + { + // to ensure "schema" is required (not null) + if (schema == null) + { + throw new ArgumentNullException("schema is a required property for EntityBase and cannot be null"); + } + this.Schema = schema; + } + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public string Schema { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as EntityBase).AreEqual; + } + + /// + /// Returns true if EntityBase instances are equal + /// + /// Instance of EntityBase to be compared + /// Boolean + public bool Equals(EntityBase input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Schema != null) + { + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/.openapi-generator/FILES b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/.openapi-generator/FILES index 2a5dbfbe6e6f..05aeba36d54c 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/.openapi-generator/FILES @@ -23,12 +23,14 @@ docs/Category.md docs/ChildCat.md docs/ClassModel.md docs/ComplexQuadrilateral.md +docs/CopyActivity.md docs/DanishPig.md docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md docs/Drawing.md +docs/EntityBase.md docs/EnumArrays.md docs/EnumClass.md docs/EnumTest.md @@ -155,11 +157,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md index edb2cb56cfa6..701078a164d2 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md @@ -176,11 +176,13 @@ Class | Method | HTTP request | Description - [Model.ChildCat](docs/ChildCat.md) - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) + - [Model.CopyActivity](docs/CopyActivity.md) - [Model.DanishPig](docs/DanishPig.md) - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.Drawing](docs/Drawing.md) + - [Model.EntityBase](docs/EntityBase.md) - [Model.EnumArrays](docs/EnumArrays.md) - [Model.EnumClass](docs/EnumClass.md) - [Model.EnumTest](docs/EnumTest.md) diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/CopyActivity.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/CopyActivity.md new file mode 100644 index 000000000000..6fe25862b72d --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**CopyActivitytt** | **string** | | + +[[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/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/EntityBase.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/EntityBase.md new file mode 100644 index 000000000000..2e4e018f7add --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..ddd13c677214 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,75 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Fact] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + + /// + /// Test the property 'CopyActivitytt' + /// + [Fact] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..0178210290cd --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,76 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using Xunit; + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Fact] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test deserialize a CopyActivity from type EntityBase + /// + [Fact] + public void CopyActivityDeserializeFromEntityBaseTest() + { + // TODO uncomment below to test deserialize a CopyActivity from type EntityBase + //Assert.IsType(JsonConvert.DeserializeObject(new CopyActivity().ToJson())); + } + + /// + /// Test the property 'Schema' + /// + [Fact] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..a40fff415396 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,222 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + [DataContract(Name = "CopyActivity")] + public partial class CopyActivity : EntityBase, IEquatable, IValidatableObject + { + /// + /// Defines Schema + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + [EnumMember(Value = "ScopeActivity")] + ScopeActivity = 1 + } + + + /// + /// Gets or Sets Schema + /// + + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public SchemaEnum Schema + { + get{ return _Schema;} + set + { + _Schema = value; + _flagSchema = true; + } + } + private SchemaEnum _Schema; + private bool _flagSchema; + + /// + /// Returns false as Schema should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeSchema() + { + return _flagSchema; + } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected CopyActivity() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// schema (required) (default to SchemaEnum.ScopeActivity). + /// copyActivitytt (required). + public CopyActivity(SchemaEnum schema = SchemaEnum.ScopeActivity, string copyActivitytt = default(string)) : base() + { + this._Schema = schema; + // to ensure "copyActivitytt" is required (not null) + if (copyActivitytt == null) + { + throw new ArgumentNullException("copyActivitytt is a required property for CopyActivity and cannot be null"); + } + this._CopyActivitytt = copyActivitytt; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets CopyActivitytt + /// + [DataMember(Name = "copyActivitytt", IsRequired = true, EmitDefaultValue = true)] + public string CopyActivitytt + { + get{ return _CopyActivitytt;} + set + { + _CopyActivitytt = value; + _flagCopyActivitytt = true; + } + } + private string _CopyActivitytt; + private bool _flagCopyActivitytt; + + /// + /// Returns false as CopyActivitytt should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeCopyActivitytt() + { + return _flagCopyActivitytt; + } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as CopyActivity).AreEqual; + } + + /// + /// Returns true if CopyActivity instances are equal + /// + /// Instance of CopyActivity to be compared + /// Boolean + public bool Equals(CopyActivity input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + if (this.CopyActivitytt != null) + { + hashCode = (hashCode * 59) + this.CopyActivitytt.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + foreach (var x in base.BaseValidate(validationContext)) + { + yield return x; + } + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..e799fbff06a4 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,176 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using JsonSubTypes; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + [DataContract(Name = "EntityBase")] + [JsonConverter(typeof(JsonSubtypes), "Schema")] + [JsonSubtypes.KnownSubType(typeof(CopyActivity), "ScopeActivity")] + public partial class EntityBase : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected EntityBase() + { + this.AdditionalProperties = new Dictionary(); + } + /// + /// Initializes a new instance of the class. + /// + /// schema (required). + public EntityBase(string schema = default(string)) + { + // to ensure "schema" is required (not null) + if (schema == null) + { + throw new ArgumentNullException("schema is a required property for EntityBase and cannot be null"); + } + this._Schema = schema; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public string Schema + { + get{ return _Schema;} + set + { + _Schema = value; + _flagSchema = true; + } + } + private string _Schema; + private bool _flagSchema; + + /// + /// Returns false as Schema should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeSchema() + { + return _flagSchema; + } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as EntityBase).AreEqual; + } + + /// + /// Returns true if EntityBase instances are equal + /// + /// Instance of EntityBase to be compared + /// Boolean + public bool Equals(EntityBase input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Schema != null) + { + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + return this.BaseValidate(validationContext); + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + protected IEnumerable BaseValidate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/.openapi-generator/FILES index a465aeaf1e0d..d7c560eb3a68 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/.openapi-generator/FILES @@ -21,12 +21,14 @@ docs/Category.md docs/ChildCat.md docs/ClassModel.md docs/ComplexQuadrilateral.md +docs/CopyActivity.md docs/DanishPig.md docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md docs/Drawing.md +docs/EntityBase.md docs/EnumArrays.md docs/EnumClass.md docs/EnumTest.md @@ -151,11 +153,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md index 250413ebcf89..22643d3b4c58 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md @@ -162,11 +162,13 @@ Class | Method | HTTP request | Description - [Model.ChildCat](ChildCat.md) - [Model.ClassModel](ClassModel.md) - [Model.ComplexQuadrilateral](ComplexQuadrilateral.md) + - [Model.CopyActivity](CopyActivity.md) - [Model.DanishPig](DanishPig.md) - [Model.DateOnlyClass](DateOnlyClass.md) - [Model.DeprecatedObject](DeprecatedObject.md) - [Model.Dog](Dog.md) - [Model.Drawing](Drawing.md) + - [Model.EntityBase](EntityBase.md) - [Model.EnumArrays](EnumArrays.md) - [Model.EnumClass](EnumClass.md) - [Model.EnumTest](EnumTest.md) diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/CopyActivity.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/CopyActivity.md new file mode 100644 index 000000000000..6fe25862b72d --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**CopyActivitytt** | **string** | | + +[[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/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/EntityBase.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/EntityBase.md new file mode 100644 index 000000000000..2e4e018f7add --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..4cb898ecfdd8 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Test] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Test] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + /// + /// Test the property 'CopyActivitytt' + /// + [Test] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..bc27f8235385 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,66 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Test] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Test] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7c5d0f5e8a65 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,156 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + [DataContract(Name = "CopyActivity")] + public partial class CopyActivity : EntityBase, IEquatable + { + /// + /// Defines Schema + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + [EnumMember(Value = "ScopeActivity")] + ScopeActivity = 1 + } + + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public SchemaEnum Schema { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected CopyActivity() { } + /// + /// Initializes a new instance of the class. + /// + /// schema (required) (default to SchemaEnum.ScopeActivity). + /// copyActivitytt (required). + public CopyActivity(SchemaEnum schema = SchemaEnum.ScopeActivity, string copyActivitytt = default(string)) : base() + { + this.Schema = schema; + // to ensure "copyActivitytt" is required (not null) + if (copyActivitytt == null) + { + throw new ArgumentNullException("copyActivitytt is a required property for CopyActivity and cannot be null"); + } + this.CopyActivitytt = copyActivitytt; + } + + /// + /// Gets or Sets CopyActivitytt + /// + [DataMember(Name = "copyActivitytt", IsRequired = true, EmitDefaultValue = true)] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as CopyActivity); + } + + /// + /// Returns true if CopyActivity instances are equal + /// + /// Instance of CopyActivity to be compared + /// Boolean + public bool Equals(CopyActivity input) + { + if (input == null) + { + return false; + } + return base.Equals(input) && + ( + this.Schema == input.Schema || + this.Schema.Equals(input.Schema) + ) && base.Equals(input) && + ( + this.CopyActivitytt == input.CopyActivitytt || + (this.CopyActivitytt != null && + this.CopyActivitytt.Equals(input.CopyActivitytt)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + if (this.CopyActivitytt != null) + { + hashCode = (hashCode * 59) + this.CopyActivitytt.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..202e6a29e279 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,128 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + [DataContract(Name = "EntityBase")] + public partial class EntityBase : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected EntityBase() { } + /// + /// Initializes a new instance of the class. + /// + /// schema (required). + public EntityBase(string schema = default(string)) + { + // to ensure "schema" is required (not null) + if (schema == null) + { + throw new ArgumentNullException("schema is a required property for EntityBase and cannot be null"); + } + this.Schema = schema; + } + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public string Schema { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as EntityBase); + } + + /// + /// Returns true if EntityBase instances are equal + /// + /// Instance of EntityBase to be compared + /// Boolean + public bool Equals(EntityBase input) + { + if (input == null) + { + return false; + } + return + ( + this.Schema == input.Schema || + (this.Schema != null && + this.Schema.Equals(input.Schema)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Schema != null) + { + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/.openapi-generator/FILES index a465aeaf1e0d..d7c560eb3a68 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/.openapi-generator/FILES @@ -21,12 +21,14 @@ docs/Category.md docs/ChildCat.md docs/ClassModel.md docs/ComplexQuadrilateral.md +docs/CopyActivity.md docs/DanishPig.md docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md docs/Drawing.md +docs/EntityBase.md docs/EnumArrays.md docs/EnumClass.md docs/EnumTest.md @@ -151,11 +153,13 @@ src/Org.OpenAPITools/Model/Category.cs src/Org.OpenAPITools/Model/ChildCat.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs +src/Org.OpenAPITools/Model/CopyActivity.cs src/Org.OpenAPITools/Model/DanishPig.cs src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/Drawing.cs +src/Org.OpenAPITools/Model/EntityBase.cs src/Org.OpenAPITools/Model/EnumArrays.cs src/Org.OpenAPITools/Model/EnumClass.cs src/Org.OpenAPITools/Model/EnumTest.cs diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md index 250413ebcf89..22643d3b4c58 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md @@ -162,11 +162,13 @@ Class | Method | HTTP request | Description - [Model.ChildCat](ChildCat.md) - [Model.ClassModel](ClassModel.md) - [Model.ComplexQuadrilateral](ComplexQuadrilateral.md) + - [Model.CopyActivity](CopyActivity.md) - [Model.DanishPig](DanishPig.md) - [Model.DateOnlyClass](DateOnlyClass.md) - [Model.DeprecatedObject](DeprecatedObject.md) - [Model.Dog](Dog.md) - [Model.Drawing](Drawing.md) + - [Model.EntityBase](EntityBase.md) - [Model.EnumArrays](EnumArrays.md) - [Model.EnumClass](EnumClass.md) - [Model.EnumTest](EnumTest.md) diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml index 780d21e19bfa..1214bb1bea44 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/api/openapi.yaml @@ -2872,6 +2872,31 @@ components: uuid: format: uuid type: string + CopyActivity: + allOf: + - $ref: '#/components/schemas/EntityBase' + properties: + $schema: + enum: + - ScopeActivity + type: string + copyActivitytt: + type: string + required: + - $schema + - copyActivitytt + type: object + EntityBase: + discriminator: + mapping: + ScopeActivity: '#/components/schemas/CopyActivity' + propertyName: $schema + properties: + $schema: + type: string + required: + - $schema + type: object _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/CopyActivity.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/CopyActivity.md new file mode 100644 index 000000000000..6fe25862b72d --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/CopyActivity.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.CopyActivity + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | [default to SchemaEnum.ScopeActivity] +**CopyActivitytt** | **string** | | + +[[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/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/EntityBase.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/EntityBase.md new file mode 100644 index 000000000000..2e4e018f7add --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/EntityBase.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.EntityBase + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | **string** | | + +[[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/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs new file mode 100644 index 000000000000..4cb898ecfdd8 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/CopyActivityTests.cs @@ -0,0 +1,74 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing CopyActivity + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class CopyActivityTests : IDisposable + { + // TODO uncomment below to declare an instance variable for CopyActivity + //private CopyActivity instance; + + public CopyActivityTests() + { + // TODO uncomment below to create an instance of CopyActivity + //instance = new CopyActivity(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of CopyActivity + /// + [Test] + public void CopyActivityInstanceTest() + { + // TODO uncomment below to test "IsType" CopyActivity + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Test] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + /// + /// Test the property 'CopyActivitytt' + /// + [Test] + public void CopyActivityttTest() + { + // TODO unit test for the property 'CopyActivitytt' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs new file mode 100644 index 000000000000..bc27f8235385 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/EntityBaseTests.cs @@ -0,0 +1,66 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Linq; +using System.IO; +using System.Collections.Generic; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; +using NUnit.Framework; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing EntityBase + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class EntityBaseTests : IDisposable + { + // TODO uncomment below to declare an instance variable for EntityBase + //private EntityBase instance; + + public EntityBaseTests() + { + // TODO uncomment below to create an instance of EntityBase + //instance = new EntityBase(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of EntityBase + /// + [Test] + public void EntityBaseInstanceTest() + { + // TODO uncomment below to test "IsType" EntityBase + //Assert.IsType(instance); + } + + /// + /// Test the property 'Schema' + /// + [Test] + public void SchemaTest() + { + // TODO unit test for the property 'Schema' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs new file mode 100644 index 000000000000..7c5d0f5e8a65 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/CopyActivity.cs @@ -0,0 +1,156 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// CopyActivity + /// + [DataContract(Name = "CopyActivity")] + public partial class CopyActivity : EntityBase, IEquatable + { + /// + /// Defines Schema + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum SchemaEnum + { + /// + /// Enum ScopeActivity for value: ScopeActivity + /// + [EnumMember(Value = "ScopeActivity")] + ScopeActivity = 1 + } + + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public SchemaEnum Schema { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected CopyActivity() { } + /// + /// Initializes a new instance of the class. + /// + /// schema (required) (default to SchemaEnum.ScopeActivity). + /// copyActivitytt (required). + public CopyActivity(SchemaEnum schema = SchemaEnum.ScopeActivity, string copyActivitytt = default(string)) : base() + { + this.Schema = schema; + // to ensure "copyActivitytt" is required (not null) + if (copyActivitytt == null) + { + throw new ArgumentNullException("copyActivitytt is a required property for CopyActivity and cannot be null"); + } + this.CopyActivitytt = copyActivitytt; + } + + /// + /// Gets or Sets CopyActivitytt + /// + [DataMember(Name = "copyActivitytt", IsRequired = true, EmitDefaultValue = true)] + public string CopyActivitytt { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class CopyActivity {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append(" CopyActivitytt: ").Append(CopyActivitytt).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as CopyActivity); + } + + /// + /// Returns true if CopyActivity instances are equal + /// + /// Instance of CopyActivity to be compared + /// Boolean + public bool Equals(CopyActivity input) + { + if (input == null) + { + return false; + } + return base.Equals(input) && + ( + this.Schema == input.Schema || + this.Schema.Equals(input.Schema) + ) && base.Equals(input) && + ( + this.CopyActivitytt == input.CopyActivitytt || + (this.CopyActivitytt != null && + this.CopyActivitytt.Equals(input.CopyActivitytt)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + if (this.CopyActivitytt != null) + { + hashCode = (hashCode * 59) + this.CopyActivitytt.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs new file mode 100644 index 000000000000..202e6a29e279 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/EntityBase.cs @@ -0,0 +1,128 @@ +/* + * 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: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; + +namespace Org.OpenAPITools.Model +{ + /// + /// EntityBase + /// + [DataContract(Name = "EntityBase")] + public partial class EntityBase : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected EntityBase() { } + /// + /// Initializes a new instance of the class. + /// + /// schema (required). + public EntityBase(string schema = default(string)) + { + // to ensure "schema" is required (not null) + if (schema == null) + { + throw new ArgumentNullException("schema is a required property for EntityBase and cannot be null"); + } + this.Schema = schema; + } + + /// + /// Gets or Sets Schema + /// + [DataMember(Name = "$schema", IsRequired = true, EmitDefaultValue = true)] + public string Schema { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class EntityBase {\n"); + sb.Append(" Schema: ").Append(Schema).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as EntityBase); + } + + /// + /// Returns true if EntityBase instances are equal + /// + /// Instance of EntityBase to be compared + /// Boolean + public bool Equals(EntityBase input) + { + if (input == null) + { + return false; + } + return + ( + this.Schema == input.Schema || + (this.Schema != null && + this.Schema.Equals(input.Schema)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Schema != null) + { + hashCode = (hashCode * 59) + this.Schema.GetHashCode(); + } + return hashCode; + } + } + + } + +}