diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java index 02043c013d9..f3a13797b97 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java @@ -679,6 +679,12 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen { for (CodegenProperty property : model.nonNullableVars) { patchProperty(enumRefs, model, property); } + + List overriddenProperties = model.vars.stream().filter(v -> model.allVars.stream().anyMatch(a -> a.baseName.equals(v.baseName) && a.dataType != v.dataType)).collect(Collectors.toList()); + for (CodegenProperty overridden : overriddenProperties) { + // if the current model overrides an allOf property, use the overridden property + model.allVars.set(model.allVars.indexOf(model.allVars.stream().filter(a -> a.baseName.equals(overridden.baseName)).findFirst().get()), overridden); + } } return processed; } 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 5b726d69b9f..601c6ff10af 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 @@ -2861,3 +2861,30 @@ components: propertyName: $schema mapping: ScopeActivity: '#/components/schemas/CopyActivity' + Result: + type: object + properties: + code: + type: string + description: Result code + uuid: + type: string + description: Result unique identifier + data: + type: object + description: list of named parameters for current message + additionalProperties: + type: string + TestResult: + type: object + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: "#/components/schemas/TestResultCode" + TestResultCode: + type: string + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED 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 930f03400a8..f38df6b6b4e 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 @@ -103,6 +103,7 @@ docs/models/RequiredClassRequiredNotnullableEnumString.md docs/models/RequiredClassRequiredNullableEnumInteger.md docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md docs/models/RequiredClassRequiredNullableEnumString.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -121,6 +122,8 @@ docs/models/TestEnumParametersEnumQueryIntegerParameter.md docs/models/TestEnumParametersRequestEnumFormString.md docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -261,6 +264,7 @@ src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -279,6 +283,8 @@ src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 3c7d8aa3954..8328178d7ee 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 @@ -2617,6 +2617,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 66af4c79a0e..9956d150f63 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 @@ -223,6 +223,8 @@ namespace Org.OpenAPITools.Client return TestEnumParametersRequestEnumFormStringValueConverter.ToJsonValue(testEnumParametersRequestEnumFormString); if (obj is TestEnumParametersRequestEnumFormStringArrayInner testEnumParametersRequestEnumFormStringArrayInner) return TestEnumParametersRequestEnumFormStringArrayInnerValueConverter.ToJsonValue(testEnumParametersRequestEnumFormStringArrayInner); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is ZebraType zebraType) return ZebraTypeValueConverter.ToJsonValue(zebraType); if (obj is ZeroBasedEnum zeroBasedEnum) 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 08b8e054141..5790e75e558 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 @@ -154,6 +154,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerOnlyNullableJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -177,6 +178,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerJsonConverter()); _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerNullableJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4b0b889b708 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..4d237900519 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 1facc69aec6..cf07e6ecd75 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 @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -222,6 +225,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -235,6 +239,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 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 @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 560c039d70a..c7e931e3147 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 @@ -227,6 +227,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 dbbc08df796..afb53358728 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 @@ -122,6 +122,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -135,6 +136,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4b0b889b708 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..4d237900519 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 930f03400a8..f38df6b6b4e 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 @@ -103,6 +103,7 @@ docs/models/RequiredClassRequiredNotnullableEnumString.md docs/models/RequiredClassRequiredNullableEnumInteger.md docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md docs/models/RequiredClassRequiredNullableEnumString.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -121,6 +122,8 @@ docs/models/TestEnumParametersEnumQueryIntegerParameter.md docs/models/TestEnumParametersRequestEnumFormString.md docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -261,6 +264,7 @@ src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -279,6 +283,8 @@ src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 3c7d8aa3954..8328178d7ee 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 @@ -2617,6 +2617,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 66af4c79a0e..9956d150f63 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 @@ -223,6 +223,8 @@ namespace Org.OpenAPITools.Client return TestEnumParametersRequestEnumFormStringValueConverter.ToJsonValue(testEnumParametersRequestEnumFormString); if (obj is TestEnumParametersRequestEnumFormStringArrayInner testEnumParametersRequestEnumFormStringArrayInner) return TestEnumParametersRequestEnumFormStringArrayInnerValueConverter.ToJsonValue(testEnumParametersRequestEnumFormStringArrayInner); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is ZebraType zebraType) return ZebraTypeValueConverter.ToJsonValue(zebraType); if (obj is ZeroBasedEnum zeroBasedEnum) 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 08b8e054141..5790e75e558 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 @@ -154,6 +154,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerOnlyNullableJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -177,6 +178,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerJsonConverter()); _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerNullableJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4b0b889b708 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..4d237900519 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 1facc69aec6..cf07e6ecd75 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 @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -222,6 +225,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -235,6 +239,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 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 @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 560c039d70a..c7e931e3147 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 @@ -227,6 +227,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 dbbc08df796..afb53358728 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 @@ -122,6 +122,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -135,6 +136,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4b0b889b708 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..4d237900519 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 77738c830b4..01c68e2c380 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES @@ -103,6 +103,7 @@ docs/models/RequiredClassRequiredNotnullableEnumString.md docs/models/RequiredClassRequiredNullableEnumInteger.md docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md docs/models/RequiredClassRequiredNullableEnumString.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -121,6 +122,8 @@ docs/models/TestEnumParametersEnumQueryIntegerParameter.md docs/models/TestEnumParametersRequestEnumFormString.md docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -263,6 +266,7 @@ src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -281,6 +285,8 @@ src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 3c7d8aa3954..8328178d7ee 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml @@ -2617,6 +2617,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 025b10ff3f0..03ae546ce3a 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 @@ -222,6 +222,8 @@ namespace Org.OpenAPITools.Client return TestEnumParametersRequestEnumFormStringValueConverter.ToJsonValue(testEnumParametersRequestEnumFormString); if (obj is TestEnumParametersRequestEnumFormStringArrayInner testEnumParametersRequestEnumFormStringArrayInner) return TestEnumParametersRequestEnumFormStringArrayInnerValueConverter.ToJsonValue(testEnumParametersRequestEnumFormStringArrayInner); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is ZebraType zebraType) return ZebraTypeValueConverter.ToJsonValue(zebraType); if (obj is ZeroBasedEnum zeroBasedEnum) 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 80118c6a1ec..735d995a188 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 @@ -156,6 +156,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerOnlyNullableJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -179,6 +180,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerJsonConverter()); _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerNullableJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4012eec09fb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..46ccc750b1c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 a24733a7c11..30863e11947 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -224,6 +227,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -237,6 +241,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 caef1201677..f802dff08c4 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 @@ -228,6 +228,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 1557552a768..97df4fac688 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 @@ -126,6 +126,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -139,6 +140,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4a1e1fc3b49 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,240 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()!); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..3cd60d60295 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,240 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + string? codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..2523ba0414a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,177 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 a24733a7c11..30863e11947 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -224,6 +227,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -237,6 +241,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 0dfe6afc4b1..06a92c878bf 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 @@ -226,6 +226,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 47783040097..5a01ba45bd9 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 @@ -124,6 +124,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -137,6 +138,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4012eec09fb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..46ccc750b1c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 a24733a7c11..30863e11947 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -224,6 +227,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -237,6 +241,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 caef1201677..f802dff08c4 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 @@ -228,6 +228,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 9914ab629e3..b1617fe9684 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 @@ -126,6 +126,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -139,6 +140,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); @@ -228,6 +232,7 @@ namespace Org.OpenAPITools.Client new QuadrilateralInterfaceSerializationContext(), new ReadOnlyFirstSerializationContext(), new RequiredClassSerializationContext(), + new ResultSerializationContext(), new ReturnSerializationContext(), new RolesReportsHashSerializationContext(), new RolesReportsHashRoleSerializationContext(), @@ -241,6 +246,8 @@ namespace Org.OpenAPITools.Client new TestCollectionEndingWithWordListSerializationContext(), new TestCollectionEndingWithWordListObjectSerializationContext(), new TestInlineFreeformAdditionalPropertiesRequestSerializationContext(), + new TestResultSerializationContext(), + new TestResultCodeSerializationContext(), new TriangleSerializationContext(), new TriangleInterfaceSerializationContext(), new UserSerializationContext(), diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..73b13637845 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,248 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()!); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } + + /// + /// The ResultSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(Result))] + public partial class ResultSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..ccb64f19162 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,248 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + string? codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } + + /// + /// The TestResultSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(TestResult))] + public partial class TestResultSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..4d4a979a814 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResultCode.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 System.Text.Json.Serialization.Metadata; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } + + + /// + /// The TestResultCodeSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(TestResultCode))] + public partial class TestResultCodeSerializationContext : 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 77738c830b4..01c68e2c380 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/.openapi-generator/FILES @@ -103,6 +103,7 @@ docs/models/RequiredClassRequiredNotnullableEnumString.md docs/models/RequiredClassRequiredNullableEnumInteger.md docs/models/RequiredClassRequiredNullableEnumIntegerOnly.md docs/models/RequiredClassRequiredNullableEnumString.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -121,6 +122,8 @@ docs/models/TestEnumParametersEnumQueryIntegerParameter.md docs/models/TestEnumParametersRequestEnumFormString.md docs/models/TestEnumParametersRequestEnumFormStringArrayInner.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -263,6 +266,7 @@ src/Org.OpenAPITools/Model/RequiredClassRequiredNotnullableEnumString.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumInteger.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumIntegerOnly.cs src/Org.OpenAPITools/Model/RequiredClassRequiredNullableEnumString.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -281,6 +285,8 @@ src/Org.OpenAPITools/Model/TestEnumParametersEnumQueryIntegerParameter.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormString.cs src/Org.OpenAPITools/Model/TestEnumParametersRequestEnumFormStringArrayInner.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 3c7d8aa3954..8328178d7ee 100644 --- a/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/api/openapi.yaml @@ -2617,6 +2617,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 025b10ff3f0..03ae546ce3a 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 @@ -222,6 +222,8 @@ namespace Org.OpenAPITools.Client return TestEnumParametersRequestEnumFormStringValueConverter.ToJsonValue(testEnumParametersRequestEnumFormString); if (obj is TestEnumParametersRequestEnumFormStringArrayInner testEnumParametersRequestEnumFormStringArrayInner) return TestEnumParametersRequestEnumFormStringArrayInnerValueConverter.ToJsonValue(testEnumParametersRequestEnumFormStringArrayInner); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is ZebraType zebraType) return ZebraTypeValueConverter.ToJsonValue(zebraType); if (obj is ZeroBasedEnum zeroBasedEnum) 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 80118c6a1ec..735d995a188 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 @@ -156,6 +156,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumIntegerOnlyNullableJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassRequiredNullableEnumStringNullableJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -179,6 +180,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerJsonConverter()); _jsonOptions.Converters.Add(new TestEnumParametersRequestEnumFormStringArrayInnerNullableJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4012eec09fb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..46ccc750b1c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/FormModels/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 a24733a7c11..30863e11947 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/.openapi-generator/FILES @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -224,6 +227,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -237,6 +241,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 caef1201677..f802dff08c4 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 @@ -228,6 +228,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 1557552a768..97df4fac688 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 @@ -126,6 +126,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -139,6 +140,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4a1e1fc3b49 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,240 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()!); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..3cd60d60295 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,240 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + string? codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..2523ba0414a --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,177 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 a24733a7c11..30863e11947 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/.openapi-generator/FILES @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -224,6 +227,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -237,6 +241,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 0dfe6afc4b1..06a92c878bf 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 @@ -226,6 +226,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 47783040097..5a01ba45bd9 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 @@ -124,6 +124,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -137,6 +138,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4012eec09fb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..46ccc750b1c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 a24733a7c11..30863e11947 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/.openapi-generator/FILES @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -224,6 +227,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -237,6 +241,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/Result.md b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 caef1201677..f802dff08c4 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 @@ -228,6 +228,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 9914ab629e3..b1617fe9684 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 @@ -126,6 +126,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -139,6 +140,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); @@ -228,6 +232,7 @@ namespace Org.OpenAPITools.Client new QuadrilateralInterfaceSerializationContext(), new ReadOnlyFirstSerializationContext(), new RequiredClassSerializationContext(), + new ResultSerializationContext(), new ReturnSerializationContext(), new RolesReportsHashSerializationContext(), new RolesReportsHashRoleSerializationContext(), @@ -241,6 +246,8 @@ namespace Org.OpenAPITools.Client new TestCollectionEndingWithWordListSerializationContext(), new TestCollectionEndingWithWordListObjectSerializationContext(), new TestInlineFreeformAdditionalPropertiesRequestSerializationContext(), + new TestResultSerializationContext(), + new TestResultCodeSerializationContext(), new TriangleSerializationContext(), new TriangleInterfaceSerializationContext(), new UserSerializationContext(), diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..73b13637845 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,248 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()!); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } + + /// + /// The ResultSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(Result))] + public partial class ResultSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..ccb64f19162 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,248 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option?> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option?> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary? Data { get { return this.DataOption; } set { this.DataOption = new(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string? Uuid { get { return this.UuidOption; } set { this.UuidOption = new(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option?> data = default; + Option uuid = 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 "code": + string? codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option?>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)!); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } + + /// + /// The TestResultSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(TestResult))] + public partial class TestResultSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..4d4a979a814 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResultCode.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 System.Text.Json.Serialization.Metadata; +using Org.OpenAPITools.Client; + +namespace Org.OpenAPITools.Model +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string? rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } + + + /// + /// The TestResultCodeSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(TestResultCode))] + public partial class TestResultCodeSerializationContext : 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 1facc69aec6..cf07e6ecd75 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 @@ -87,6 +87,7 @@ docs/models/Quadrilateral.md docs/models/QuadrilateralInterface.md docs/models/ReadOnlyFirst.md docs/models/RequiredClass.md +docs/models/Result.md docs/models/Return.md docs/models/RolesReportsHash.md docs/models/RolesReportsHashRole.md @@ -100,6 +101,8 @@ docs/models/Tag.md docs/models/TestCollectionEndingWithWordList.md docs/models/TestCollectionEndingWithWordListObject.md docs/models/TestInlineFreeformAdditionalPropertiesRequest.md +docs/models/TestResult.md +docs/models/TestResultCode.md docs/models/Triangle.md docs/models/TriangleInterface.md docs/models/User.md @@ -222,6 +225,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -235,6 +239,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 6a83f7a1e48..c26549a5a7c 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 @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/Result.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/Result.md new file mode 100644 index 00000000000..fa828d5d34d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/TestResult.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/TestResult.md new file mode 100644 index 00000000000..7e9e1e7cf5d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] +**Uuid** | **string** | Result unique identifier | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/TestResultCode.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/TestResultCode.md new file mode 100644 index 00000000000..524c76d8d8c --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..222a85fbdd6 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..3507e490550 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,56 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..ad0d6377bf4 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,83 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + } +} 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 560c039d70a..c7e931e3147 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 @@ -227,6 +227,8 @@ namespace Org.OpenAPITools.Client return RequiredClass.RequiredNullableEnumIntegerOnlyEnumToJsonValue(requiredClassRequiredNullableEnumIntegerOnlyEnum).ToString(); if (obj is RequiredClass.RequiredNullableEnumStringEnum requiredClassRequiredNullableEnumStringEnum) return RequiredClass.RequiredNullableEnumStringEnumToJsonValue(requiredClassRequiredNullableEnumStringEnum); + if (obj is TestResultCode testResultCode) + return TestResultCodeValueConverter.ToJsonValue(testResultCode); if (obj is Zebra.TypeEnum zebraTypeEnum) return Zebra.TypeEnumToJsonValue(zebraTypeEnum); if (obj is ZeroBasedEnum zeroBasedEnum) 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 dbbc08df796..afb53358728 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 @@ -122,6 +122,7 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new QuadrilateralInterfaceJsonConverter()); _jsonOptions.Converters.Add(new ReadOnlyFirstJsonConverter()); _jsonOptions.Converters.Add(new RequiredClassJsonConverter()); + _jsonOptions.Converters.Add(new ResultJsonConverter()); _jsonOptions.Converters.Add(new ReturnJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashJsonConverter()); _jsonOptions.Converters.Add(new RolesReportsHashRoleJsonConverter()); @@ -135,6 +136,9 @@ namespace Org.OpenAPITools.Client _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListJsonConverter()); _jsonOptions.Converters.Add(new TestCollectionEndingWithWordListObjectJsonConverter()); _jsonOptions.Converters.Add(new TestInlineFreeformAdditionalPropertiesRequestJsonConverter()); + _jsonOptions.Converters.Add(new TestResultJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeJsonConverter()); + _jsonOptions.Converters.Add(new TestResultCodeNullableJsonConverter()); _jsonOptions.Converters.Add(new TriangleJsonConverter()); _jsonOptions.Converters.Add(new TriangleInterfaceJsonConverter()); _jsonOptions.Converters.Add(new UserJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..4b0b889b708 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// Result + /// + public partial class Result : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public Result(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Result code + /// + /// Result code + [JsonPropertyName("code")] + public string Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class ResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override Result 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 code = default; + Option> data = default; + Option uuid = 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 "code": + code = new Option(utf8JsonReader.GetString()); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result."); + + return new Result(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, result, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions) + { + if (result.CodeOption.IsSet && result.Code == null) + throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result."); + + if (result.DataOption.IsSet && result.Data == null) + throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result."); + + if (result.UuidOption.IsSet && result.Uuid == null) + throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result."); + + if (result.CodeOption.IsSet) + writer.WriteString("code", result.Code); + + if (result.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions); + } + if (result.UuidOption.IsSet) + writer.WriteString("uuid", result.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..4d237900519 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,238 @@ +// +/* + * 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 +{ + /// + /// TestResult + /// + public partial class TestResult : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// code + /// list of named parameters for current message + /// Result unique identifier + [JsonConstructor] + public TestResult(Option code = default, Option> data = default, Option uuid = default) + { + CodeOption = code; + DataOption = data; + UuidOption = uuid; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Code + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option CodeOption { get; private set; } + + /// + /// Gets or Sets Code + /// + [JsonPropertyName("code")] + public TestResultCode? Code { get { return this.CodeOption; } set { this.CodeOption = new Option(value); } } + + /// + /// Used to track the state of Data + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option> DataOption { get; private set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [JsonPropertyName("data")] + public Dictionary Data { get { return this.DataOption; } set { this.DataOption = new Option>(value); } } + + /// + /// Used to track the state of Uuid + /// + [JsonIgnore] + [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] + public Option UuidOption { get; private set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [JsonPropertyName("uuid")] + public string Uuid { get { return this.UuidOption; } set { this.UuidOption = new Option(value); } } + + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Data: ").Append(Data).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\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) + { + yield break; + } + } + + /// + /// A Json converter for type + /// + public class TestResultJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override TestResult 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 code = default; + Option> data = default; + Option uuid = 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 "code": + string codeRawValue = utf8JsonReader.GetString(); + if (codeRawValue != null) + code = new Option(TestResultCodeValueConverter.FromStringOrDefault(codeRawValue)); + break; + case "data": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + data = new Option>(JsonSerializer.Deserialize>(ref utf8JsonReader, jsonSerializerOptions)); + break; + case "uuid": + uuid = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (code.IsSet && code.Value == null) + throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult."); + + if (data.IsSet && data.Value == null) + throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult."); + + if (uuid.IsSet && uuid.Value == null) + throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult."); + + return new TestResult(code, data, uuid); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, testResult, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions) + { + if (testResult.DataOption.IsSet && testResult.Data == null) + throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult."); + + if (testResult.UuidOption.IsSet && testResult.Uuid == null) + throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult."); + + if (testResult.CodeOption.IsSet) + { + var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code.Value); + writer.WriteString("code", codeRawValue); + } + if (testResult.DataOption.IsSet) + { + writer.WritePropertyName("data"); + JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions); + } + if (testResult.UuidOption.IsSet) + writer.WriteString("uuid", testResult.Uuid); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..0fc06c04a67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,175 @@ +// +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + MANUALAPPROVALREQUIRED = 2 + } + + /// + /// Converts to and from the JSON value + /// + public static class TestResultCodeValueConverter + { + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode FromString(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + throw new NotImplementedException($"Could not convert value to type TestResultCode: '{value}'"); + } + + /// + /// Parses a given value to + /// + /// + /// + public static TestResultCode? FromStringOrDefault(string value) + { + if (value.Equals("APPROVED")) + return TestResultCode.APPROVED; + + if (value.Equals("MANUAL_APPROVAL_REQUIRED")) + return TestResultCode.MANUALAPPROVALREQUIRED; + + return null; + } + + /// + /// Converts the to the json value + /// + /// + /// + /// + public static string ToJsonValue(TestResultCode value) + { + if (value == TestResultCode.APPROVED) + return "APPROVED"; + + if (value == TestResultCode.MANUALAPPROVALREQUIRED) + return "MANUAL_APPROVAL_REQUIRED"; + + throw new NotImplementedException($"Value could not be handled: '{value}'"); + } + } + + /// + /// A Json converter for type + /// + /// + public class TestResultCodeJsonConverter : JsonConverter + { + /// + /// Returns a from the Json object + /// + /// + /// + /// + /// + public override TestResultCode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the TestResultCode to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode.ToString()); + } + } + + /// + /// A Json converter for type + /// + public class TestResultCodeNullableJsonConverter : JsonConverter + { + /// + /// Returns a TestResultCode from the Json object + /// + /// + /// + /// + /// + public override TestResultCode? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + string rawValue = reader.GetString(); + + TestResultCode? result = rawValue == null + ? null + : TestResultCodeValueConverter.FromStringOrDefault(rawValue); + + if (result != null) + return result.Value; + + throw new JsonException(); + } + + /// + /// Writes the DateTime to the json writer + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, TestResultCode? testResultCode, JsonSerializerOptions options) + { + writer.WriteStringValue(testResultCode?.ToString() ?? "null"); + } + } +} 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 8bda3ce3fe7..e17404c21c3 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/.openapi-generator/FILES @@ -85,6 +85,7 @@ docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md docs/RequiredClass.md +docs/Result.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -99,6 +100,8 @@ docs/Tag.md docs/TestCollectionEndingWithWordList.md docs/TestCollectionEndingWithWordListObject.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestResult.md +docs/TestResultCode.md docs/Triangle.md docs/TriangleInterface.md docs/User.md @@ -212,6 +215,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -225,6 +229,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.cs diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md index e1623481f18..058363dea46 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/README.md @@ -271,6 +271,7 @@ Class | Method | HTTP request | Description - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Model.RequiredClass](docs/RequiredClass.md) + - [Model.Result](docs/Result.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) @@ -284,6 +285,8 @@ Class | Method | HTTP request | Description - [Model.TestCollectionEndingWithWordList](docs/TestCollectionEndingWithWordList.md) - [Model.TestCollectionEndingWithWordListObject](docs/TestCollectionEndingWithWordListObject.md) - [Model.TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [Model.TestResult](docs/TestResult.md) + - [Model.TestResultCode](docs/TestResultCode.md) - [Model.Triangle](docs/Triangle.md) - [Model.TriangleInterface](docs/TriangleInterface.md) - [Model.User](docs/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/Result.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/Result.md new file mode 100644 index 00000000000..d2de0c7ac04 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/TestResult.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/TestResult.md new file mode 100644 index 00000000000..d70eaf2b64a --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/TestResultCode.md b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/TestResultCode.md new file mode 100644 index 00000000000..4a22a8343e3 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/docs/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..cc80b7f80cc --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..8150b945382 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,57 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..916176cf056 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..83f7d269943 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,162 @@ +/* + * 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 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 +{ + /// + /// Result + /// + [DataContract(Name = "Result")] + public partial class Result : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code. + /// Result unique identifier. + /// list of named parameters for current message. + public Result(string code = default(string), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Result code + /// + /// Result code + [DataMember(Name = "code", EmitDefaultValue = false)] + public string Code { get; set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 Result).AreEqual; + } + + /// + /// Returns true if Result instances are equal + /// + /// Instance of Result to be compared + /// Boolean + public bool Equals(Result 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.Code != null) + { + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + } + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.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) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..183db18df05 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,158 @@ +/* + * 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 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 +{ + /// + /// TestResult + /// + [DataContract(Name = "TestResult")] + public partial class TestResult : IEquatable, IValidatableObject + { + + /// + /// Gets or Sets Code + /// + [DataMember(Name = "code", EmitDefaultValue = false)] + public TestResultCode? Code { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// code. + /// Result unique identifier. + /// list of named parameters for current message. + public TestResult(TestResultCode? code = default(TestResultCode?), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 TestResult).AreEqual; + } + + /// + /// Returns true if TestResult instances are equal + /// + /// Instance of TestResult to be compared + /// Boolean + public bool Equals(TestResult 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; + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.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) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..cb5db7dfc9b --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,50 @@ +/* + * 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 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 +{ + /// + /// Result code + /// + /// Result code + [JsonConverter(typeof(StringEnumConverter))] + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + [EnumMember(Value = "APPROVED")] + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + [EnumMember(Value = "MANUAL_APPROVAL_REQUIRED")] + MANUALAPPROVALREQUIRED = 2 + } + +} 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 b0909e10d1a..0e4363b86ac 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 @@ -85,6 +85,7 @@ docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md docs/RequiredClass.md +docs/Result.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -99,6 +100,8 @@ docs/Tag.md docs/TestCollectionEndingWithWordList.md docs/TestCollectionEndingWithWordListObject.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestResult.md +docs/TestResultCode.md docs/Triangle.md docs/TriangleInterface.md docs/User.md @@ -211,6 +214,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -224,6 +228,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 055197c0676..260041aa2d2 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md @@ -259,6 +259,7 @@ Class | Method | HTTP request | Description - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Model.RequiredClass](docs/RequiredClass.md) + - [Model.Result](docs/Result.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) @@ -272,6 +273,8 @@ Class | Method | HTTP request | Description - [Model.TestCollectionEndingWithWordList](docs/TestCollectionEndingWithWordList.md) - [Model.TestCollectionEndingWithWordListObject](docs/TestCollectionEndingWithWordListObject.md) - [Model.TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [Model.TestResult](docs/TestResult.md) + - [Model.TestResultCode](docs/TestResultCode.md) - [Model.Triangle](docs/Triangle.md) - [Model.TriangleInterface](docs/TriangleInterface.md) - [Model.User](docs/User.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 6a83f7a1e48..c26549a5a7c 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 @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/Result.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/Result.md new file mode 100644 index 00000000000..d2de0c7ac04 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/TestResult.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/TestResult.md new file mode 100644 index 00000000000..d70eaf2b64a --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/TestResultCode.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/TestResultCode.md new file mode 100644 index 00000000000..4a22a8343e3 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..cc80b7f80cc --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..8150b945382 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,57 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..916176cf056 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..83f7d269943 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,162 @@ +/* + * 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 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 +{ + /// + /// Result + /// + [DataContract(Name = "Result")] + public partial class Result : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code. + /// Result unique identifier. + /// list of named parameters for current message. + public Result(string code = default(string), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Result code + /// + /// Result code + [DataMember(Name = "code", EmitDefaultValue = false)] + public string Code { get; set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 Result).AreEqual; + } + + /// + /// Returns true if Result instances are equal + /// + /// Instance of Result to be compared + /// Boolean + public bool Equals(Result 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.Code != null) + { + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + } + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.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) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..183db18df05 --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,158 @@ +/* + * 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 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 +{ + /// + /// TestResult + /// + [DataContract(Name = "TestResult")] + public partial class TestResult : IEquatable, IValidatableObject + { + + /// + /// Gets or Sets Code + /// + [DataMember(Name = "code", EmitDefaultValue = false)] + public TestResultCode? Code { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// code. + /// Result unique identifier. + /// list of named parameters for current message. + public TestResult(TestResultCode? code = default(TestResultCode?), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 TestResult).AreEqual; + } + + /// + /// Returns true if TestResult instances are equal + /// + /// Instance of TestResult to be compared + /// Boolean + public bool Equals(TestResult 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; + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.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) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..cb5db7dfc9b --- /dev/null +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,50 @@ +/* + * 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 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 +{ + /// + /// Result code + /// + /// Result code + [JsonConverter(typeof(StringEnumConverter))] + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + [EnumMember(Value = "APPROVED")] + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + [EnumMember(Value = "MANUAL_APPROVAL_REQUIRED")] + MANUALAPPROVALREQUIRED = 2 + } + +} 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 f63a424386f..5479c71d560 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/.openapi-generator/FILES @@ -85,6 +85,7 @@ docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md docs/RequiredClass.md +docs/Result.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -99,6 +100,8 @@ docs/Tag.md docs/TestCollectionEndingWithWordList.md docs/TestCollectionEndingWithWordListObject.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestResult.md +docs/TestResultCode.md docs/Triangle.md docs/TriangleInterface.md docs/User.md @@ -214,6 +217,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -227,6 +231,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.cs diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md index de946ecd37a..b55180fbb96 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/README.md @@ -246,6 +246,7 @@ Class | Method | HTTP request | Description - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Model.RequiredClass](docs/RequiredClass.md) + - [Model.Result](docs/Result.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) @@ -259,6 +260,8 @@ Class | Method | HTTP request | Description - [Model.TestCollectionEndingWithWordList](docs/TestCollectionEndingWithWordList.md) - [Model.TestCollectionEndingWithWordListObject](docs/TestCollectionEndingWithWordListObject.md) - [Model.TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [Model.TestResult](docs/TestResult.md) + - [Model.TestResultCode](docs/TestResultCode.md) - [Model.Triangle](docs/Triangle.md) - [Model.TriangleInterface](docs/TriangleInterface.md) - [Model.User](docs/User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/Result.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/Result.md new file mode 100644 index 00000000000..d2de0c7ac04 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/TestResult.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/TestResult.md new file mode 100644 index 00000000000..d70eaf2b64a --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/TestResultCode.md b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/TestResultCode.md new file mode 100644 index 00000000000..4a22a8343e3 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/docs/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..cc80b7f80cc --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..8150b945382 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,57 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..916176cf056 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..6d39a9cf05c --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,149 @@ +/* + * 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 System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Result + /// + [DataContract(Name = "Result")] + public partial class Result : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code. + /// Result unique identifier. + /// list of named parameters for current message. + public Result(string code = default(string), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + } + + /// + /// Result code + /// + /// Result code + [DataMember(Name = "code", EmitDefaultValue = false)] + public string Code { get; set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 Result).AreEqual; + } + + /// + /// Returns true if Result instances are equal + /// + /// Instance of Result to be compared + /// Boolean + public bool Equals(Result 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.Code != null) + { + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + } + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..463ce4a7a86 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,145 @@ +/* + * 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 System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestResult + /// + [DataContract(Name = "TestResult")] + public partial class TestResult : IEquatable, IValidatableObject + { + + /// + /// Gets or Sets Code + /// + [DataMember(Name = "code", EmitDefaultValue = false)] + public TestResultCode? Code { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// code. + /// Result unique identifier. + /// list of named parameters for current message. + public TestResult(TestResultCode? code = default(TestResultCode?), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 TestResult).AreEqual; + } + + /// + /// Returns true if TestResult instances are equal + /// + /// Instance of TestResult to be compared + /// Boolean + public bool Equals(TestResult 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; + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..8d6170946d5 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,49 @@ +/* + * 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 System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Result code + /// + /// Result code + [JsonConverter(typeof(StringEnumConverter))] + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + [EnumMember(Value = "APPROVED")] + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + [EnumMember(Value = "MANUAL_APPROVAL_REQUIRED")] + MANUALAPPROVALREQUIRED = 2 + } + +} 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 f63a424386f..5479c71d560 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 @@ -85,6 +85,7 @@ docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md docs/RequiredClass.md +docs/Result.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -99,6 +100,8 @@ docs/Tag.md docs/TestCollectionEndingWithWordList.md docs/TestCollectionEndingWithWordListObject.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestResult.md +docs/TestResultCode.md docs/Triangle.md docs/TriangleInterface.md docs/User.md @@ -214,6 +217,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -227,6 +231,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 523a2d86252..a44f14756c0 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md @@ -234,6 +234,7 @@ Class | Method | HTTP request | Description - [Model.QuadrilateralInterface](docs/QuadrilateralInterface.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Model.RequiredClass](docs/RequiredClass.md) + - [Model.Result](docs/Result.md) - [Model.Return](docs/Return.md) - [Model.RolesReportsHash](docs/RolesReportsHash.md) - [Model.RolesReportsHashRole](docs/RolesReportsHashRole.md) @@ -247,6 +248,8 @@ Class | Method | HTTP request | Description - [Model.TestCollectionEndingWithWordList](docs/TestCollectionEndingWithWordList.md) - [Model.TestCollectionEndingWithWordListObject](docs/TestCollectionEndingWithWordListObject.md) - [Model.TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) + - [Model.TestResult](docs/TestResult.md) + - [Model.TestResultCode](docs/TestResultCode.md) - [Model.Triangle](docs/Triangle.md) - [Model.TriangleInterface](docs/TriangleInterface.md) - [Model.User](docs/User.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 6a83f7a1e48..c26549a5a7c 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 @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/Result.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/Result.md new file mode 100644 index 00000000000..d2de0c7ac04 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/TestResult.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/TestResult.md new file mode 100644 index 00000000000..d70eaf2b64a --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/TestResultCode.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/TestResultCode.md new file mode 100644 index 00000000000..4a22a8343e3 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..cc80b7f80cc --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Fact] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..8150b945382 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,57 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Fact] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..916176cf056 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,84 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Fact] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Fact] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + + /// + /// Test the property 'Uuid' + /// + [Fact] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + + /// + /// Test the property 'Data' + /// + [Fact] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..9854f1af92a --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,227 @@ +/* + * 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 System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Result + /// + [DataContract(Name = "Result")] + public partial class Result : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// Result code. + /// Result unique identifier. + /// list of named parameters for current message. + public Result(string code = default(string), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this._Code = code; + if (this.Code != null) + { + this._flagCode = true; + } + this._Uuid = uuid; + if (this.Uuid != null) + { + this._flagUuid = true; + } + this._Data = data; + if (this.Data != null) + { + this._flagData = true; + } + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Result code + /// + /// Result code + [DataMember(Name = "code", EmitDefaultValue = false)] + public string Code + { + get{ return _Code;} + set + { + _Code = value; + _flagCode = true; + } + } + private string _Code; + private bool _flagCode; + + /// + /// Returns false as Code should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeCode() + { + return _flagCode; + } + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid + { + get{ return _Uuid;} + set + { + _Uuid = value; + _flagUuid = true; + } + } + private string _Uuid; + private bool _flagUuid; + + /// + /// Returns false as Uuid should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeUuid() + { + return _flagUuid; + } + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data + { + get{ return _Data;} + set + { + _Data = value; + _flagData = true; + } + } + private Dictionary _Data; + private bool _flagData; + + /// + /// Returns false as Data should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeData() + { + return _flagData; + } + /// + /// 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 Result).AreEqual; + } + + /// + /// Returns true if Result instances are equal + /// + /// Instance of Result to be compared + /// Boolean + public bool Equals(Result 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.Code != null) + { + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + } + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.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) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..70c680fabad --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,225 @@ +/* + * 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 System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// TestResult + /// + [DataContract(Name = "TestResult")] + public partial class TestResult : IEquatable, IValidatableObject + { + + /// + /// Gets or Sets Code + /// + + [DataMember(Name = "code", EmitDefaultValue = false)] + public TestResultCode? Code + { + get{ return _Code;} + set + { + _Code = value; + _flagCode = true; + } + } + private TestResultCode? _Code; + private bool _flagCode; + + /// + /// Returns false as Code should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeCode() + { + return _flagCode; + } + /// + /// Initializes a new instance of the class. + /// + /// code. + /// Result unique identifier. + /// list of named parameters for current message. + public TestResult(TestResultCode? code = default(TestResultCode?), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this._Code = code; + if (this.Code != null) + { + this._flagCode = true; + } + this._Uuid = uuid; + if (this.Uuid != null) + { + this._flagUuid = true; + } + this._Data = data; + if (this.Data != null) + { + this._flagData = true; + } + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid + { + get{ return _Uuid;} + set + { + _Uuid = value; + _flagUuid = true; + } + } + private string _Uuid; + private bool _flagUuid; + + /// + /// Returns false as Uuid should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeUuid() + { + return _flagUuid; + } + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data + { + get{ return _Data;} + set + { + _Data = value; + _flagData = true; + } + } + private Dictionary _Data; + private bool _flagData; + + /// + /// Returns false as Data should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeData() + { + return _flagData; + } + /// + /// 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 TestResult).AreEqual; + } + + /// + /// Returns true if TestResult instances are equal + /// + /// Instance of TestResult to be compared + /// Boolean + public bool Equals(TestResult 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; + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.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) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..8d6170946d5 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,49 @@ +/* + * 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 System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// Result code + /// + /// Result code + [JsonConverter(typeof(StringEnumConverter))] + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + [EnumMember(Value = "APPROVED")] + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + [EnumMember(Value = "MANUAL_APPROVAL_REQUIRED")] + MANUALAPPROVALREQUIRED = 2 + } + +} 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 7a3fb0afaba..e6ef424fc4e 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/.openapi-generator/FILES @@ -83,6 +83,7 @@ docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md docs/RequiredClass.md +docs/Result.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -97,6 +98,8 @@ docs/Tag.md docs/TestCollectionEndingWithWordList.md docs/TestCollectionEndingWithWordListObject.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestResult.md +docs/TestResultCode.md docs/Triangle.md docs/TriangleInterface.md docs/User.md @@ -210,6 +213,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -223,6 +227,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.cs diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md index b7d030f82ff..d74f51324db 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/README.md @@ -220,6 +220,7 @@ Class | Method | HTTP request | Description - [Model.QuadrilateralInterface](QuadrilateralInterface.md) - [Model.ReadOnlyFirst](ReadOnlyFirst.md) - [Model.RequiredClass](RequiredClass.md) + - [Model.Result](Result.md) - [Model.Return](Return.md) - [Model.RolesReportsHash](RolesReportsHash.md) - [Model.RolesReportsHashRole](RolesReportsHashRole.md) @@ -233,6 +234,8 @@ Class | Method | HTTP request | Description - [Model.TestCollectionEndingWithWordList](TestCollectionEndingWithWordList.md) - [Model.TestCollectionEndingWithWordListObject](TestCollectionEndingWithWordListObject.md) - [Model.TestInlineFreeformAdditionalPropertiesRequest](TestInlineFreeformAdditionalPropertiesRequest.md) + - [Model.TestResult](TestResult.md) + - [Model.TestResultCode](TestResultCode.md) - [Model.Triangle](Triangle.md) - [Model.TriangleInterface](TriangleInterface.md) - [Model.User](User.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 6a83f7a1e48..c26549a5a7c 100644 --- a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/api/openapi.yaml @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/Result.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/Result.md new file mode 100644 index 00000000000..d2de0c7ac04 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/TestResult.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/TestResult.md new file mode 100644 index 00000000000..d70eaf2b64a --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/TestResultCode.md b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/TestResultCode.md new file mode 100644 index 00000000000..4a22a8343e3 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/docs/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..4f4e584dfd0 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,82 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Test] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Test] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + /// + /// Test the property 'Uuid' + /// + [Test] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + /// + /// Test the property 'Data' + /// + [Test] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..e20845dec5f --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,58 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Test] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..cdd554aa4b5 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,82 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Test] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Test] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + /// + /// Test the property 'Uuid' + /// + [Test] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + /// + /// Test the property 'Data' + /// + [Test] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..44098f32236 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,158 @@ +/* + * 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 +{ + /// + /// Result + /// + [DataContract(Name = "Result")] + public partial class Result : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// Result code. + /// Result unique identifier. + /// list of named parameters for current message. + public Result(string code = default(string), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + } + + /// + /// Result code + /// + /// Result code + [DataMember(Name = "code", EmitDefaultValue = false)] + public string Code { get; set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 Result); + } + + /// + /// Returns true if Result instances are equal + /// + /// Instance of Result to be compared + /// Boolean + public bool Equals(Result input) + { + if (input == null) + { + return false; + } + return + ( + this.Code == input.Code || + (this.Code != null && + this.Code.Equals(input.Code)) + ) && + ( + this.Uuid == input.Uuid || + (this.Uuid != null && + this.Uuid.Equals(input.Uuid)) + ) && + ( + this.Data == input.Data || + this.Data != null && + input.Data != null && + this.Data.SequenceEqual(input.Data) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Code != null) + { + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + } + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..4f22d0d87fe --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,153 @@ +/* + * 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 +{ + /// + /// TestResult + /// + [DataContract(Name = "TestResult")] + public partial class TestResult : IEquatable + { + + /// + /// Gets or Sets Code + /// + [DataMember(Name = "code", EmitDefaultValue = false)] + public TestResultCode? Code { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// code. + /// Result unique identifier. + /// list of named parameters for current message. + public TestResult(TestResultCode? code = default(TestResultCode?), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 TestResult); + } + + /// + /// Returns true if TestResult instances are equal + /// + /// Instance of TestResult to be compared + /// Boolean + public bool Equals(TestResult input) + { + if (input == null) + { + return false; + } + return + ( + this.Code == input.Code || + this.Code.Equals(input.Code) + ) && + ( + this.Uuid == input.Uuid || + (this.Uuid != null && + this.Uuid.Equals(input.Uuid)) + ) && + ( + this.Data == input.Data || + this.Data != null && + input.Data != null && + this.Data.SequenceEqual(input.Data) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..d65be650c1f --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/net9/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,47 @@ +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + [JsonConverter(typeof(StringEnumConverter))] + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + [EnumMember(Value = "APPROVED")] + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + [EnumMember(Value = "MANUAL_APPROVAL_REQUIRED")] + MANUALAPPROVALREQUIRED = 2 + } + +} 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 7a3fb0afaba..e6ef424fc4e 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 @@ -83,6 +83,7 @@ docs/Quadrilateral.md docs/QuadrilateralInterface.md docs/ReadOnlyFirst.md docs/RequiredClass.md +docs/Result.md docs/Return.md docs/RolesReportsHash.md docs/RolesReportsHashRole.md @@ -97,6 +98,8 @@ docs/Tag.md docs/TestCollectionEndingWithWordList.md docs/TestCollectionEndingWithWordListObject.md docs/TestInlineFreeformAdditionalPropertiesRequest.md +docs/TestResult.md +docs/TestResultCode.md docs/Triangle.md docs/TriangleInterface.md docs/User.md @@ -210,6 +213,7 @@ src/Org.OpenAPITools/Model/Quadrilateral.cs src/Org.OpenAPITools/Model/QuadrilateralInterface.cs src/Org.OpenAPITools/Model/ReadOnlyFirst.cs src/Org.OpenAPITools/Model/RequiredClass.cs +src/Org.OpenAPITools/Model/Result.cs src/Org.OpenAPITools/Model/Return.cs src/Org.OpenAPITools/Model/RolesReportsHash.cs src/Org.OpenAPITools/Model/RolesReportsHashRole.cs @@ -223,6 +227,8 @@ src/Org.OpenAPITools/Model/Tag.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs +src/Org.OpenAPITools/Model/TestResult.cs +src/Org.OpenAPITools/Model/TestResultCode.cs src/Org.OpenAPITools/Model/Triangle.cs src/Org.OpenAPITools/Model/TriangleInterface.cs src/Org.OpenAPITools/Model/User.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 b7d030f82ff..d74f51324db 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md @@ -220,6 +220,7 @@ Class | Method | HTTP request | Description - [Model.QuadrilateralInterface](QuadrilateralInterface.md) - [Model.ReadOnlyFirst](ReadOnlyFirst.md) - [Model.RequiredClass](RequiredClass.md) + - [Model.Result](Result.md) - [Model.Return](Return.md) - [Model.RolesReportsHash](RolesReportsHash.md) - [Model.RolesReportsHashRole](RolesReportsHashRole.md) @@ -233,6 +234,8 @@ Class | Method | HTTP request | Description - [Model.TestCollectionEndingWithWordList](TestCollectionEndingWithWordList.md) - [Model.TestCollectionEndingWithWordListObject](TestCollectionEndingWithWordListObject.md) - [Model.TestInlineFreeformAdditionalPropertiesRequest](TestInlineFreeformAdditionalPropertiesRequest.md) + - [Model.TestResult](TestResult.md) + - [Model.TestResultCode](TestResultCode.md) - [Model.Triangle](Triangle.md) - [Model.TriangleInterface](TriangleInterface.md) - [Model.User](User.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 6a83f7a1e48..c26549a5a7c 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 @@ -2795,6 +2795,33 @@ components: required: - $schema type: object + Result: + properties: + code: + description: Result code + type: string + uuid: + description: Result unique identifier + type: string + data: + additionalProperties: + type: string + description: list of named parameters for current message + type: object + type: object + TestResult: + allOf: + - $ref: '#/components/schemas/Result' + properties: + code: + $ref: '#/components/schemas/TestResultCode' + type: object + TestResultCode: + description: Result code + enum: + - APPROVED + - MANUAL_APPROVAL_REQUIRED + type: string _foo_get_default_response: example: string: diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/Result.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/Result.md new file mode 100644 index 00000000000..d2de0c7ac04 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/Result.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.Result + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **string** | Result code | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/TestResult.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/TestResult.md new file mode 100644 index 00000000000..d70eaf2b64a --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/TestResult.md @@ -0,0 +1,12 @@ +# Org.OpenAPITools.Model.TestResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Code** | **TestResultCode** | | [optional] +**Uuid** | **string** | Result unique identifier | [optional] +**Data** | **Dictionary<string, string>** | list of named parameters for current message | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/TestResultCode.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/TestResultCode.md new file mode 100644 index 00000000000..4a22a8343e3 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/TestResultCode.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.TestResultCode +Result code + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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/ResultTests.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs new file mode 100644 index 00000000000..4f4e584dfd0 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/ResultTests.cs @@ -0,0 +1,82 @@ +/* + * 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 Result + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class ResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for Result + //private Result instance; + + public ResultTests() + { + // TODO uncomment below to create an instance of Result + //instance = new Result(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of Result + /// + [Test] + public void ResultInstanceTest() + { + // TODO uncomment below to test "IsType" Result + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Test] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + /// + /// Test the property 'Uuid' + /// + [Test] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + /// + /// Test the property 'Data' + /// + [Test] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs new file mode 100644 index 00000000000..e20845dec5f --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultCodeTests.cs @@ -0,0 +1,58 @@ +/* + * 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 TestResultCode + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultCodeTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResultCode + //private TestResultCode instance; + + public TestResultCodeTests() + { + // TODO uncomment below to create an instance of TestResultCode + //instance = new TestResultCode(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResultCode + /// + [Test] + public void TestResultCodeInstanceTest() + { + // TODO uncomment below to test "IsType" TestResultCode + //Assert.IsType(instance); + } + + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs new file mode 100644 index 00000000000..cdd554aa4b5 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/TestResultTests.cs @@ -0,0 +1,82 @@ +/* + * 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 TestResult + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class TestResultTests : IDisposable + { + // TODO uncomment below to declare an instance variable for TestResult + //private TestResult instance; + + public TestResultTests() + { + // TODO uncomment below to create an instance of TestResult + //instance = new TestResult(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of TestResult + /// + [Test] + public void TestResultInstanceTest() + { + // TODO uncomment below to test "IsType" TestResult + //Assert.IsType(instance); + } + + /// + /// Test the property 'Code' + /// + [Test] + public void CodeTest() + { + // TODO unit test for the property 'Code' + } + /// + /// Test the property 'Uuid' + /// + [Test] + public void UuidTest() + { + // TODO unit test for the property 'Uuid' + } + /// + /// Test the property 'Data' + /// + [Test] + public void DataTest() + { + // TODO unit test for the property 'Data' + } + } +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs new file mode 100644 index 00000000000..44098f32236 --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/Result.cs @@ -0,0 +1,158 @@ +/* + * 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 +{ + /// + /// Result + /// + [DataContract(Name = "Result")] + public partial class Result : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// Result code. + /// Result unique identifier. + /// list of named parameters for current message. + public Result(string code = default(string), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + } + + /// + /// Result code + /// + /// Result code + [DataMember(Name = "code", EmitDefaultValue = false)] + public string Code { get; set; } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 Result {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 Result); + } + + /// + /// Returns true if Result instances are equal + /// + /// Instance of Result to be compared + /// Boolean + public bool Equals(Result input) + { + if (input == null) + { + return false; + } + return + ( + this.Code == input.Code || + (this.Code != null && + this.Code.Equals(input.Code)) + ) && + ( + this.Uuid == input.Uuid || + (this.Uuid != null && + this.Uuid.Equals(input.Uuid)) + ) && + ( + this.Data == input.Data || + this.Data != null && + input.Data != null && + this.Data.SequenceEqual(input.Data) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Code != null) + { + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + } + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs new file mode 100644 index 00000000000..4f22d0d87fe --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResult.cs @@ -0,0 +1,153 @@ +/* + * 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 +{ + /// + /// TestResult + /// + [DataContract(Name = "TestResult")] + public partial class TestResult : IEquatable + { + + /// + /// Gets or Sets Code + /// + [DataMember(Name = "code", EmitDefaultValue = false)] + public TestResultCode? Code { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// code. + /// Result unique identifier. + /// list of named parameters for current message. + public TestResult(TestResultCode? code = default(TestResultCode?), string uuid = default(string), Dictionary data = default(Dictionary)) + { + this.Code = code; + this.Uuid = uuid; + this.Data = data; + } + + /// + /// Result unique identifier + /// + /// Result unique identifier + [DataMember(Name = "uuid", EmitDefaultValue = false)] + public string Uuid { get; set; } + + /// + /// list of named parameters for current message + /// + /// list of named parameters for current message + [DataMember(Name = "data", EmitDefaultValue = false)] + public Dictionary Data { 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 TestResult {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" Uuid: ").Append(Uuid).Append("\n"); + sb.Append(" Data: ").Append(Data).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 TestResult); + } + + /// + /// Returns true if TestResult instances are equal + /// + /// Instance of TestResult to be compared + /// Boolean + public bool Equals(TestResult input) + { + if (input == null) + { + return false; + } + return + ( + this.Code == input.Code || + this.Code.Equals(input.Code) + ) && + ( + this.Uuid == input.Uuid || + (this.Uuid != null && + this.Uuid.Equals(input.Uuid)) + ) && + ( + this.Data == input.Data || + this.Data != null && + input.Data != null && + this.Data.SequenceEqual(input.Data) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Code.GetHashCode(); + if (this.Uuid != null) + { + hashCode = (hashCode * 59) + this.Uuid.GetHashCode(); + } + if (this.Data != null) + { + hashCode = (hashCode * 59) + this.Data.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs new file mode 100644 index 00000000000..d65be650c1f --- /dev/null +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Model/TestResultCode.cs @@ -0,0 +1,47 @@ +/* + * 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 +{ + /// + /// Result code + /// + /// Result code + [JsonConverter(typeof(StringEnumConverter))] + public enum TestResultCode + { + /// + /// Enum APPROVED for value: APPROVED + /// + [EnumMember(Value = "APPROVED")] + APPROVED = 1, + + /// + /// Enum MANUALAPPROVALREQUIRED for value: MANUAL_APPROVAL_REQUIRED + /// + [EnumMember(Value = "MANUAL_APPROVAL_REQUIRED")] + MANUALAPPROVALREQUIRED = 2 + } + +}