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 595d919150f1..b632d3b06d3b 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 @@ -603,6 +603,7 @@ public Map postProcessAllModels(Map objs) property.name = patchPropertyName(model, camelize(property.baseType)); property.isNullable = true; patchPropertyVendorExtensions(property); + property.vendorExtensions.put("x-base-name", model.name.substring(model.name.lastIndexOf('_') + 1)); } } @@ -613,6 +614,7 @@ public Map postProcessAllModels(Map objs) property.name = patchPropertyName(model, camelize(property.baseType)); property.isNullable = true; patchPropertyVendorExtensions(property); + property.vendorExtensions.put("x-base-name", model.name.substring(model.name.lastIndexOf('_') + 1)); } } } diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache index 2b8fe63b201e..189acfd74218 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache @@ -360,10 +360,24 @@ {{#model.hasDiscriminatorWithNonEmptyMapping}} {{#composedSchemas.oneOf}} {{^vendorExtensions.x-duplicated-data-type}} - if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} != null) { + if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} != null) + {{#isPrimitiveType}} + {{#isString}} + writer.WriteString("{{vendorExtensions.x-base-name}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value); + {{/isString}} + {{#isBoolean}} + writer.WriteBoolean("{{vendorExtensions.x-base-name}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value.Value); + {{/isBoolean}} + {{#isNumeric}} + writer.WriteNumber("{{vendorExtensions.x-base-name}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value.Value); + {{/isNumeric}} + {{/isPrimitiveType}} + {{^isPrimitiveType}} + { {{baseType}}JsonConverter {{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}} = ({{baseType}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}.GetType())); {{#lambda.camelcase_sanitize_param}}{{baseType}}JsonConverter{{/lambda.camelcase_sanitize_param}}.WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}, jsonSerializerOptions); } + {{/isPrimitiveType}} {{/vendorExtensions.x-duplicated-data-type}} {{/composedSchemas.oneOf}} @@ -373,10 +387,23 @@ {{#composedSchemas}} {{#anyOf}} if ({{#lambda.joinWithAmpersand}}{{^required}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.IsSet {{/required}}{{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}} != null{{/lambda.joinWithAmpersand}}) + {{#isPrimitiveType}} + {{#isString}} + writer.WriteString("{{vendorExtensions.x-base-name}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value); + {{/isString}} + {{#isBoolean}} + writer.WriteBoolean("{{vendorExtensions.x-base-name}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value.Value); + {{/isBoolean}} + {{#isNumeric}} + writer.WriteNumber("{{vendorExtensions.x-base-name}}", {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value.Value); + {{/isNumeric}} + {{/isPrimitiveType}} + {{^isPrimitiveType}} { {{datatypeWithEnum}}JsonConverter {{datatypeWithEnum}}JsonConverter = ({{datatypeWithEnum}}JsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert({{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}.GetType())); {{datatypeWithEnum}}JsonConverter.WriteProperties(writer, {{#lambda.camelcase_sanitize_param}}{{model.classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}{{^required}}Option.Value{{/required}}, jsonSerializerOptions); } + {{/isPrimitiveType}} {{/anyOf}} {{/composedSchemas}} 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 21570bfa9ac4..6809791b5e49 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 @@ -1250,6 +1250,32 @@ paths: application/json: schema: $ref: '#/components/schemas/ArrayOfEnums' + /fake/mixed/anyOf: + get: + tags: + - fake + summary: Test mixed type anyOf deserialization + operationId: getMixedAnyOf + responses: + 200: + description: Got mixed anyOf + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + /fake/mixed/oneOf: + get: + tags: + - fake + summary: Test mixed type oneOf deserialization + operationId: getMixedOneOf + responses: + 200: + description: Got mixed oneOf + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' /country: post: operationId: getCountry @@ -2753,6 +2779,41 @@ components: type: array items: $ref: '#/components/schemas/Custom-Variableobject-Response' + MixedOneOf: + properties: + content: + oneOf: + - type: string + - type: boolean + # JsonReader will give back C# System.Int64 regardless of format. + - type: integer + format: uint8 + # JsonReader will give back C# System.Double regardless of format. + - type: number + format: float32 + - type: object + $ref: '#/components/schemas/MixedSubId' + description: Mixed oneOf types for testing + MixedAnyOf: + properties: + content: + anyOf: + - type: string + - type: boolean + # JsonReader will give back C# System.Int64 regardless of format. + - type: integer + format: uint8 + # JsonReader will give back C# System.Double regardless of format. + - type: number + format: float32 + - type: object + $ref: '#/components/schemas/MixedSubId' + + description: Mixed anyOf types for testing + MixedSubId: + properties: + id: + type: string # this class ensures that the CodegenProperties are sorted correctly # https://github.com/OpenAPITools/openapi-generator/issues/18607 MixLog: 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 99f3f12f924a..45c476af3183 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 @@ -63,7 +63,12 @@ docs/models/Mammal.md docs/models/MapTest.md docs/models/MapTestMapOfEnumStringValue.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -215,7 +220,12 @@ src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 b4ab1bc2b817..c64890a06346 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 @@ -1182,6 +1182,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2528,6 +2554,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2950,6 +2992,26 @@ components: - unknown - notUnknown type: string + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md index d87f500d56c8..8e9abed3c227 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index f57f666628d8..00017fc42140 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 0be949dd5922..01eeeb00511b 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -169,6 +169,48 @@ public interface IFakeApi : IApi /// <> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -588,6 +630,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -869,6 +935,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2477,6 +2583,392 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedAnyOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedOneOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 750d414c6e25..c706302171c4 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 @@ -101,7 +101,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueJsonConverter()); _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueNullableJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs index 1be5661d9936..bb21f9f9bafa 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Mammal.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..034925ec9884 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..ac63c98cab68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,283 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new Option(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..2045930184e5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..0d8f554b0213 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,261 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..9766a9f410eb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,174 @@ +// +/* + * 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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs index 10061a2c228b..48dabfec1544 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs index 19e395f1de47..20323876ffc3 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Pig.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs index 3d333d7958fb..28fc8e1d46ec 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs index d4883a363a21..d6710bed609c 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Shape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2d9fb2cbb334..03781409be7d 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs index d31d2948c652..9c9fee0db0b6 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Triangle.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 be38ed26d98c..0bf16fb19b73 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 @@ -55,7 +55,12 @@ docs/models/LiteralStringClass.md docs/models/Mammal.md docs/models/MapTest.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -184,7 +189,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 e4713d2621c4..f772773afefa 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 @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md index 46abf3716ffe..959c6b75e78d 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index ee61aa929639..0cabe51ed289 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 677a0ab31c6e..f0ab0b4ca0a3 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -169,6 +169,48 @@ public interface IFakeApi : IApi /// <> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -588,6 +630,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -869,6 +935,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2477,6 +2583,392 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedAnyOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedOneOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 8ea6690254f5..e12f1ae97793 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 @@ -85,7 +85,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MammalJsonConverter()); _jsonOptions.Converters.Add(new MapTestJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs index 1be5661d9936..bb21f9f9bafa 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Mammal.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..034925ec9884 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..ac63c98cab68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,283 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new Option(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..2045930184e5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..0d8f554b0213 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,261 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..9766a9f410eb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,174 @@ +// +/* + * 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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs index 10061a2c228b..48dabfec1544 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs index 19e395f1de47..20323876ffc3 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Pig.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs index 3d333d7958fb..28fc8e1d46ec 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs index d4883a363a21..d6710bed609c 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Shape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2d9fb2cbb334..03781409be7d 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs index d31d2948c652..9c9fee0db0b6 100644 --- a/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net4.7/Petstore/src/Org.OpenAPITools/Model/Triangle.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 99f3f12f924a..45c476af3183 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 @@ -63,7 +63,12 @@ docs/models/Mammal.md docs/models/MapTest.md docs/models/MapTestMapOfEnumStringValue.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -215,7 +220,12 @@ src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 b4ab1bc2b817..c64890a06346 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 @@ -1182,6 +1182,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2528,6 +2554,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2950,6 +2992,26 @@ components: - unknown - notUnknown type: string + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/FakeApi.md index d87f500d56c8..8e9abed3c227 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index f57f666628d8..00017fc42140 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 0be949dd5922..01eeeb00511b 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -169,6 +169,48 @@ public interface IFakeApi : IApi /// <> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -588,6 +630,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -869,6 +935,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2477,6 +2583,392 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedAnyOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedOneOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 750d414c6e25..c706302171c4 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 @@ -101,7 +101,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueJsonConverter()); _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueNullableJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs index 1be5661d9936..bb21f9f9bafa 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..034925ec9884 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..ac63c98cab68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,283 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new Option(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..2045930184e5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..0d8f554b0213 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,261 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..9766a9f410eb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,174 @@ +// +/* + * 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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs index 10061a2c228b..48dabfec1544 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pig.cs index 19e395f1de47..20323876ffc3 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Pig.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs index 3d333d7958fb..28fc8e1d46ec 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Shape.cs index d4883a363a21..d6710bed609c 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Shape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2d9fb2cbb334..03781409be7d 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs index d31d2948c652..9c9fee0db0b6 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 be38ed26d98c..0bf16fb19b73 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 @@ -55,7 +55,12 @@ docs/models/LiteralStringClass.md docs/models/Mammal.md docs/models/MapTest.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -184,7 +189,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 e4713d2621c4..f772773afefa 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 @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/FakeApi.md index 46abf3716ffe..959c6b75e78d 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index ee61aa929639..0cabe51ed289 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 677a0ab31c6e..f0ab0b4ca0a3 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -169,6 +169,48 @@ public interface IFakeApi : IApi /// <> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -588,6 +630,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -869,6 +935,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2477,6 +2583,392 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedAnyOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedOneOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 8ea6690254f5..e12f1ae97793 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 @@ -85,7 +85,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MammalJsonConverter()); _jsonOptions.Converters.Add(new MapTestJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs index 1be5661d9936..bb21f9f9bafa 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..034925ec9884 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..ac63c98cab68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,283 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new Option(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..2045930184e5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..0d8f554b0213 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,261 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..9766a9f410eb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,174 @@ +// +/* + * 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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs index 10061a2c228b..48dabfec1544 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pig.cs index 19e395f1de47..20323876ffc3 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Pig.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs index 3d333d7958fb..28fc8e1d46ec 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Shape.cs index d4883a363a21..d6710bed609c 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Shape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2d9fb2cbb334..03781409be7d 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs index d31d2948c652..9c9fee0db0b6 100644 --- a/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net4.8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 deef0a5de482..bc72f8c05ba1 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/.openapi-generator/FILES @@ -63,7 +63,12 @@ docs/models/Mammal.md docs/models/MapTest.md docs/models/MapTestMapOfEnumStringValue.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -217,7 +222,12 @@ src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MapTestMapOfEnumStringValue.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 b4ab1bc2b817..c64890a06346 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/api/openapi.yaml @@ -1182,6 +1182,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2528,6 +2554,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2950,6 +2992,26 @@ components: - unknown - notUnknown type: string + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/FakeApi.md index 187a580b89a2..47134bd4322c 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index 090238dc8cb0..86a438a3ec9b 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs index 218bb51d7b46..0dc06a0c06e6 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Api/FakeApi.cs @@ -169,6 +169,48 @@ public interface IFakeApi : IApi /// <> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -588,6 +630,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -869,6 +935,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2483,6 +2589,394 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedAnyOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedOneOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 4a6a9ad09078..f35ca51d2d2a 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 @@ -103,7 +103,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueJsonConverter()); _jsonOptions.Converters.Add(new MapTestMapOfEnumStringValueNullableJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs index 1be5661d9936..bb21f9f9bafa 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Mammal.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..1131c62aca4d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..267b12864224 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,283 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string String { get { return this.StringOption; } set { this.StringOption = new(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..bc3be394b2ee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..0d8f554b0213 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,261 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..ec9706d5dae7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,174 @@ +// +/* + * 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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs index 10061a2c228b..48dabfec1544 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/NullableShape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs index 19e395f1de47..20323876ffc3 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Pig.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs index 3d333d7958fb..28fc8e1d46ec 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs index d4883a363a21..d6710bed609c 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Shape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2d9fb2cbb334..03781409be7d 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs index d31d2948c652..9c9fee0db0b6 100644 --- a/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/FormModels/src/Org.OpenAPITools/Model/Triangle.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 a94acc41bff3..afb25a1c17e1 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/.openapi-generator/FILES @@ -55,7 +55,12 @@ docs/models/LiteralStringClass.md docs/models/Mammal.md docs/models/MapTest.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -186,7 +191,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 e4713d2621c4..f772773afefa 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/FakeApi.md index 94cf293ed111..65edbb26576a 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index fe8397be218c..fba8b26855ce 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs index 2bb291f16f5e..1f45ab88e837 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Api/FakeApi.cs @@ -171,6 +171,48 @@ public interface IFakeApi : IApi /// <?> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <?> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <?> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -590,6 +632,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -871,6 +937,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler? OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2485,6 +2591,394 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedAnyOf? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedOneOf? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 d96b864d7822..8be0791ee4fb 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 @@ -89,7 +89,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MammalJsonConverter()); _jsonOptions.Converters.Add(new MapTestJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs index f80ef9bd3ebf..7b9b43229ae7 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Mammal.cs @@ -234,17 +234,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..3e232be60ec2 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,180 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent? Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..5c8664dea483 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,285 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string? String { get { return this.StringOption; } set { this.StringOption = new(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId? MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string? varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId? mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..eb2bdcfa5c7b --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,180 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent? Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..e99a18fb4df1 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,263 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string? String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId? MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string? varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId? mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..9cebccc7634d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,176 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string? Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs index 5cb7a024bb8a..a7c757fa4fd2 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableShape.cs @@ -210,12 +210,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs index 0a26dc0fb341..16d9d5273a41 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pig.cs @@ -210,12 +210,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs index bb00a21cf69a..4f0ea3aecbf6 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -210,12 +210,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs index c19f3a8af06a..e5a7afdfa516 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Shape.cs @@ -210,12 +210,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs index e6d8735bd1ba..790ce838468f 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -210,12 +210,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs index 4d8f03d60a0b..64ef28431d47 100644 --- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Triangle.cs @@ -234,17 +234,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 a94acc41bff3..afb25a1c17e1 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/.openapi-generator/FILES @@ -55,7 +55,12 @@ docs/models/LiteralStringClass.md docs/models/Mammal.md docs/models/MapTest.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -186,7 +191,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 e4713d2621c4..f772773afefa 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/FakeApi.md index 94cf293ed111..65edbb26576a 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index e982dbf36e34..73bf47831d1c 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 987454df7ee3..c47a501885ea 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -169,6 +169,48 @@ public interface IFakeApi : IApi /// <> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -588,6 +630,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -869,6 +935,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2483,6 +2589,394 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedAnyOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedOneOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 968f832b0456..cb0e43c85272 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 @@ -87,7 +87,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MammalJsonConverter()); _jsonOptions.Converters.Add(new MapTestJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs index 1be5661d9936..bb21f9f9bafa 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Mammal.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..1131c62aca4d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..267b12864224 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,283 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string String { get { return this.StringOption; } set { this.StringOption = new(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..bc3be394b2ee --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..0d8f554b0213 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,261 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..ec9706d5dae7 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,174 @@ +// +/* + * 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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs index 10061a2c228b..48dabfec1544 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs index 19e395f1de47..20323876ffc3 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Pig.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs index 3d333d7958fb..28fc8e1d46ec 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs index d4883a363a21..d6710bed609c 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Shape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2d9fb2cbb334..03781409be7d 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs index d31d2948c652..9c9fee0db0b6 100644 --- a/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/Petstore/src/Org.OpenAPITools/Model/Triangle.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 a94acc41bff3..afb25a1c17e1 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/.openapi-generator/FILES @@ -55,7 +55,12 @@ docs/models/LiteralStringClass.md docs/models/Mammal.md docs/models/MapTest.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -186,7 +191,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 e4713d2621c4..f772773afefa 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/FakeApi.md index 94cf293ed111..65edbb26576a 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index fe8397be218c..fba8b26855ce 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs index 2bb291f16f5e..1f45ab88e837 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Api/FakeApi.cs @@ -171,6 +171,48 @@ public interface IFakeApi : IApi /// <?> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <?> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <?> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -590,6 +632,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -871,6 +937,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler? OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler? OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler? OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2485,6 +2591,394 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedAnyOf? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + + httpRequestMessageLocalVar.Method = HttpMethod.Get; + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf? Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : null; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.MixedOneOf? result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 bb5e0663eb8d..03e2cd6ecb87 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 @@ -89,7 +89,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MammalJsonConverter()); _jsonOptions.Converters.Add(new MapTestJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); @@ -190,7 +195,12 @@ public HostConfiguration(IServiceCollection services) new MammalSerializationContext(), new MapTestSerializationContext(), new MixLogSerializationContext(), + new MixedAnyOfSerializationContext(), + new MixedAnyOfContentSerializationContext(), + new MixedOneOfSerializationContext(), + new MixedOneOfContentSerializationContext(), new MixedPropertiesAndAdditionalPropertiesClassSerializationContext(), + new MixedSubIdSerializationContext(), new Model200ResponseSerializationContext(), new ModelClientSerializationContext(), new NameSerializationContext(), diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs index 15c63b5d7850..1fe6a61d59aa 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Mammal.cs @@ -235,17 +235,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..c39a6b816045 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,188 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent? Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } + + /// + /// The MixedAnyOfSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(MixedAnyOf))] + public partial class MixedAnyOfSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..d31b901e4831 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,293 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string? String { get { return this.StringOption; } set { this.StringOption = new(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId? MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string? varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId? mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } + + /// + /// The MixedAnyOfContentSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(MixedAnyOfContent))] + public partial class MixedAnyOfContentSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..75f39e332b68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,188 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent? Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)!); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } + + /// + /// The MixedOneOfSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(MixedOneOf))] + public partial class MixedOneOfSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..e1ea494f83df --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,271 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string? String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId? MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string? varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId? mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } + + /// + /// The MixedOneOfContentSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(MixedOneOfContent))] + public partial class MixedOneOfContentSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..788a581e5eeb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,184 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string? Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()!); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } + + /// + /// The MixedSubIdSerializationContext + /// + [JsonSourceGenerationOptions(WriteIndented = true, GenerationMode = JsonSourceGenerationMode.Metadata | JsonSourceGenerationMode.Serialization)] + [JsonSerializable(typeof(MixedSubId))] + public partial class MixedSubIdSerializationContext : JsonSerializerContext { } +} diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs index db1d9df81024..285ef1dca56a 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableShape.cs @@ -211,12 +211,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs index 88ffcca10048..863db3d9ef14 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pig.cs @@ -211,12 +211,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs index 21f614134e69..0d0572fa1f5f 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -211,12 +211,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs index 329de390e644..9ea721f310c3 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Shape.cs @@ -211,12 +211,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 01c4ee1e1ee2..421ac314d6fe 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -211,12 +211,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs index b450383d3357..adf285df1a74 100644 --- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Triangle.cs @@ -235,17 +235,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 be38ed26d98c..0bf16fb19b73 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 @@ -55,7 +55,12 @@ docs/models/LiteralStringClass.md docs/models/Mammal.md docs/models/MapTest.md docs/models/MixLog.md +docs/models/MixedAnyOf.md +docs/models/MixedAnyOfContent.md +docs/models/MixedOneOf.md +docs/models/MixedOneOfContent.md docs/models/MixedPropertiesAndAdditionalPropertiesClass.md +docs/models/MixedSubId.md docs/models/Model200Response.md docs/models/ModelClient.md docs/models/Name.md @@ -184,7 +189,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 e4713d2621c4..f772773afefa 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 @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/FakeApi.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/FakeApi.md index 46abf3716ffe..959c6b75e78d 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/FakeApi.md +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/apis/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedAnyOf.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedAnyOf.md new file mode 100644 index 000000000000..2e9a2ca23f67 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedAnyOfContent.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedAnyOfContent.md new file mode 100644 index 000000000000..141ffe5a41dc --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedAnyOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## 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/docs/models/MixedOneOf.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedOneOf.md new file mode 100644 index 000000000000..6cb1d5adff01 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedOneOfContent.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedOneOfContent.md new file mode 100644 index 000000000000..168d5ee83628 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedOneOfContent.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## 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/docs/models/MixedSubId.md b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedSubId.md new file mode 100644 index 000000000000..1df3d4002bf5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/docs/models/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs index ee61aa929639..0cabe51ed289 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Api/FakeApiTests.cs @@ -121,6 +121,28 @@ public async Task GetArrayOfEnumsAsyncTest() Assert.IsType>(model); } + /// + /// Test GetMixedAnyOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedAnyOfAsyncTest() + { + var response = await _instance.GetMixedAnyOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + + /// + /// Test GetMixedOneOf + /// + [Fact (Skip = "not implemented")] + public async Task GetMixedOneOfAsyncTest() + { + var response = await _instance.GetMixedOneOfAsync(); + var model = response.Ok(); + Assert.IsType(model); + } + /// /// Test TestAdditionalPropertiesReference /// diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..4ce302d1d047 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..53b28cc0658d --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..781b72025008 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..ee8b73d44f24 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs new file mode 100644 index 000000000000..2ed728a41b84 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools.Test/Model/MixedSubIdTests.cs @@ -0,0 +1,65 @@ +/* + * 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 MixedSubId + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedSubIdTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedSubId + //private MixedSubId instance; + + public MixedSubIdTests() + { + // TODO uncomment below to create an instance of MixedSubId + //instance = new MixedSubId(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedSubId + /// + [Fact] + public void MixedSubIdInstanceTest() + { + // TODO uncomment below to test "IsType" MixedSubId + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index ad69a02434e6..e386a6d58096 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -168,6 +168,48 @@ public interface IFakeApi : IApi /// <> Task GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Cancellation Token to cancel the request. + /// <> + Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default); + /// /// test referenced additionalProperties /// @@ -587,6 +629,30 @@ public interface IGetArrayOfEnumsApiResponse : Org.OpenAPITools.Client.IApiRespo bool IsOk { get; } } + /// + /// The + /// + public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + + /// + /// The + /// + public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk + { + /// + /// Returns true if the response is 200 Ok + /// + /// + bool IsOk { get; } + } + /// /// The /// @@ -868,6 +934,46 @@ internal void ExecuteOnErrorGetArrayOfEnums(Exception exception) OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception)); } + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedAnyOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedAnyOf; + + internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse) + { + OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedAnyOf(Exception exception) + { + OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + + /// + /// The event raised after the server response + /// + public event EventHandler OnGetMixedOneOf; + + /// + /// The event raised after an error querying the server + /// + public event EventHandler OnErrorGetMixedOneOf; + + internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse) + { + OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse)); + } + + internal void ExecuteOnErrorGetMixedOneOf(Exception exception) + { + OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception)); + } + /// /// The event raised after the server response /// @@ -2476,6 +2582,392 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); } + /// + /// Processes the server response + /// + /// + private void AfterGetMixedAnyOfDefaultImplementation(IGetMixedAnyOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedAnyOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedAnyOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedAnyOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type anyOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/anyOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedAnyOfApiResponse apiResponseLocalVar = new GetMixedAnyOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/anyOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedAnyOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedAnyOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedAnyOfDefaultImplementation(e, "/fake/mixed/anyOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedAnyOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedAnyOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedAnyOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedAnyOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + + /// + /// Processes the server response + /// + /// + private void AfterGetMixedOneOfDefaultImplementation(IGetMixedOneOfApiResponse apiResponseLocalVar) + { + bool suppressDefaultLog = false; + AfterGetMixedOneOf(ref suppressDefaultLog, apiResponseLocalVar); + if (!suppressDefaultLog) + Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path); + } + + /// + /// Processes the server response + /// + /// + /// + partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar); + + /// + /// Logs exceptions that occur while retrieving the server response + /// + /// + /// + /// + private void OnErrorGetMixedOneOfDefaultImplementation(Exception exception, string pathFormat, string path) + { + bool suppressDefaultLog = false; + OnErrorGetMixedOneOf(ref suppressDefaultLog, exception, pathFormat, path); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while sending the request to the server."); + } + + /// + /// A partial method that gives developers a way to provide customized exception handling + /// + /// + /// + /// + /// + partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path); + + /// + /// Test mixed type oneOf deserialization + /// + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default) + { + try + { + return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false); + } + catch (Exception) + { + return null; + } + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// <> + public async Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default) + { + UriBuilder uriBuilderLocalVar = new UriBuilder(); + + try + { + using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage()) + { + uriBuilderLocalVar.Host = HttpClient.BaseAddress.Host; + uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port; + uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme; + uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/fake/mixed/oneOf"; + + httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri; + + string[] acceptLocalVars = new string[] { + "application/json" + }; + + string acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars); + + if (acceptLocalVar != null) + httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar)); + httpRequestMessageLocalVar.Method = new HttpMethod("GET"); + + DateTime requestedAtLocalVar = DateTime.UtcNow; + + using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false)) + { + string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false); + + ILogger apiResponseLoggerLocalVar = LoggerFactory.CreateLogger(); + + GetMixedOneOfApiResponse apiResponseLocalVar = new GetMixedOneOfApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake/mixed/oneOf", requestedAtLocalVar, _jsonSerializerOptions); + + AfterGetMixedOneOfDefaultImplementation(apiResponseLocalVar); + + Events.ExecuteOnGetMixedOneOf(apiResponseLocalVar); + + return apiResponseLocalVar; + } + } + } + catch(Exception e) + { + OnErrorGetMixedOneOfDefaultImplementation(e, "/fake/mixed/oneOf", uriBuilderLocalVar.Path); + Events.ExecuteOnErrorGetMixedOneOf(e); + throw; + } + } + + /// + /// The + /// + public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse + { + /// + /// The logger + /// + public ILogger Logger { get; } + + /// + /// The + /// + /// + /// + /// + /// + /// + /// + /// + public GetMixedOneOfApiResponse(ILogger logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions) + { + Logger = logger; + OnCreated(httpRequestMessage, httpResponseMessage); + } + + partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage); + + /// + /// Returns true if the response is 200 Ok + /// + /// + public bool IsOk => 200 == (int)StatusCode; + + /// + /// Deserializes the response if the response is 200 Ok + /// + /// + public Org.OpenAPITools.Model.MixedOneOf Ok() + { + // This logic may be modified with the AsModel.mustache template + return IsOk + ? System.Text.Json.JsonSerializer.Deserialize(RawContent, _jsonSerializerOptions) + : default; + } + + /// + /// Returns true if the response is 200 Ok and the deserialized response is not null + /// + /// + /// + public bool TryOk(out Org.OpenAPITools.Model.MixedOneOf result) + { + result = null; + + try + { + result = Ok(); + } catch (Exception e) + { + OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200); + } + + return result != null; + } + + private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode) + { + bool suppressDefaultLog = false; + OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode); + if (!suppressDefaultLog) + Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode); + } + + partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode); + } + partial void FormatTestAdditionalPropertiesReference(Dictionary requestBody); /// 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 8ea6690254f5..e12f1ae97793 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 @@ -85,7 +85,12 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new MammalJsonConverter()); _jsonOptions.Converters.Add(new MapTestJsonConverter()); _jsonOptions.Converters.Add(new MixLogJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedAnyOfContentJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfJsonConverter()); + _jsonOptions.Converters.Add(new MixedOneOfContentJsonConverter()); _jsonOptions.Converters.Add(new MixedPropertiesAndAdditionalPropertiesClassJsonConverter()); + _jsonOptions.Converters.Add(new MixedSubIdJsonConverter()); _jsonOptions.Converters.Add(new Model200ResponseJsonConverter()); _jsonOptions.Converters.Add(new ModelClientJsonConverter()); _jsonOptions.Converters.Add(new NameJsonConverter()); diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs index 1be5661d9936..bb21f9f9bafa 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Mammal.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Mammal mammal, JsonSerializerO { writer.WriteStartObject(); - if (mammal.Whale != null) { + if (mammal.Whale != null) + { WhaleJsonConverter whaleJsonConverter = (WhaleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Whale.GetType())); whaleJsonConverter.WriteProperties(writer, mammal.Whale, jsonSerializerOptions); } - if (mammal.Zebra != null) { + if (mammal.Zebra != null) + { ZebraJsonConverter zebraJsonConverter = (ZebraJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Zebra.GetType())); zebraJsonConverter.WriteProperties(writer, mammal.Zebra, jsonSerializerOptions); } - if (mammal.Pig != null) { + if (mammal.Pig != null) + { PigJsonConverter pigJsonConverter = (PigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mammal.Pig.GetType())); pigJsonConverter.WriteProperties(writer, mammal.Pig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..034925ec9884 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedAnyOf + /// + public partial class MixedAnyOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedAnyOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf."); + + return new MixedAnyOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedAnyOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null) + throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf."); + + if (mixedAnyOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedAnyOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..ac63c98cab68 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,283 @@ +// +/* + * 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 +{ + /// + /// Mixed anyOf types for testing + /// + public partial class MixedAnyOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + /// + /// + /// + /// + public MixedAnyOfContent(Option @string, Option @bool, Option @int, Option @decimal, Option mixedSubId) + { + StringOption = @string; + BoolOption = @bool; + IntOption = @int; + DecimalOption = @decimal; + MixedSubIdOption = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of String + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option StringOption { get; private set; } + + /// + /// Gets or Sets String + /// + public string String { get { return this.StringOption; } set { this.StringOption = new Option(value); } } + + /// + /// Used to track the state of Bool + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option BoolOption { get; private set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option(value); } } + + /// + /// Used to track the state of Int + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IntOption { get; private set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get { return this.IntOption; } set { this.IntOption = new Option(value); } } + + /// + /// Used to track the state of Decimal + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option DecimalOption { get; private set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option(value); } } + + /// + /// Used to track the state of MixedSubId + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option MixedSubIdOption { get; private set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = 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 MixedAnyOfContent {\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 MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedAnyOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderAnyOf = utf8JsonReader; + while (utf8JsonReaderAnyOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderAnyOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderAnyOf.CurrentDepth) + break; + + if (utf8JsonReaderAnyOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderAnyOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + Option varStringParsedValue = varString == null + ? default + : new Option(varString); + Option varBoolParsedValue = varBool == null + ? default + : new Option(varBool); + Option varIntParsedValue = varInt == null + ? default + : new Option(varInt); + Option varDecimalParsedValue = varDecimal == null + ? default + : new Option(varDecimal); + Option mixedSubIdParsedValue = mixedSubId == null + ? default + : new Option(mixedSubId); + + return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + if (mixedAnyOfContent.StringOption.IsSet && mixedAnyOfContent.StringOption.Value != null) + writer.WriteString("content", mixedAnyOfContent.StringOption.Value); + + if (mixedAnyOfContent.BoolOption.IsSet && mixedAnyOfContent.BoolOption.Value != null) + writer.WriteBoolean("content", mixedAnyOfContent.BoolOption.Value.Value); + + if (mixedAnyOfContent.IntOption.IsSet && mixedAnyOfContent.IntOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.IntOption.Value.Value); + + if (mixedAnyOfContent.DecimalOption.IsSet && mixedAnyOfContent.DecimalOption.Value != null) + writer.WriteNumber("content", mixedAnyOfContent.DecimalOption.Value.Value); + + if (mixedAnyOfContent.MixedSubIdOption.IsSet && mixedAnyOfContent.MixedSubIdOption.Value != null) + { + MixedSubIdJsonConverter MixedSubIdJsonConverter = (MixedSubIdJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(mixedAnyOfContent.MixedSubIdOption.Value.GetType())); + MixedSubIdJsonConverter.WriteProperties(writer, mixedAnyOfContent.MixedSubIdOption.Value, jsonSerializerOptions); + } + + WriteProperties(writer, mixedAnyOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..2045930184e5 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,178 @@ +// +/* + * 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 +{ + /// + /// MixedOneOf + /// + public partial class MixedOneOf : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content + [JsonConstructor] + public MixedOneOf(Option content = default) + { + ContentOption = content; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Content + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option ContentOption { get; private set; } + + /// + /// Gets or Sets Content + /// + [JsonPropertyName("content")] + public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOfJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOf 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 content = 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 "content": + if (utf8JsonReader.TokenType != JsonTokenType.Null) + content = new Option(JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions)); + break; + default: + break; + } + } + } + + if (content.IsSet && content.Value == null) + throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf."); + + return new MixedOneOf(content); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOf, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null) + throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf."); + + if (mixedOneOf.ContentOption.IsSet) + { + writer.WritePropertyName("content"); + JsonSerializer.Serialize(writer, mixedOneOf.Content, jsonSerializerOptions); + } + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..0d8f554b0213 --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,261 @@ +// +/* + * 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 +{ + /// + /// Mixed oneOf types for testing + /// + public partial class MixedOneOfContent : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(string @string) + { + String = @string; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(bool @bool) + { + Bool = @bool; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(int @int) + { + Int = @int; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(decimal @decimal) + { + Decimal = @decimal; + OnCreated(); + } + + /// + /// Initializes a new instance of the class. + /// + /// + public MixedOneOfContent(MixedSubId mixedSubId) + { + MixedSubId = mixedSubId; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Gets or Sets String + /// + public string String { get; set; } + + /// + /// Gets or Sets Bool + /// + public bool? Bool { get; set; } + + /// + /// Gets or Sets Int + /// + public int? Int { get; set; } + + /// + /// Gets or Sets Decimal + /// + public decimal? Decimal { get; set; } + + /// + /// Gets or Sets MixedSubId + /// + public MixedSubId MixedSubId { get; set; } + + /// + /// 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 MixedOneOfContent {\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 MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedOneOfContent 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; + + string varString = default; + bool? varBool = default; + int? varInt = default; + decimal? varDecimal = default; + MixedSubId mixedSubId = default; + + Utf8JsonReader utf8JsonReaderOneOf = utf8JsonReader; + while (utf8JsonReaderOneOf.Read()) + { + if (startingTokenType == JsonTokenType.StartObject && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndObject && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (startingTokenType == JsonTokenType.StartArray && utf8JsonReaderOneOf.TokenType == JsonTokenType.EndArray && currentDepth == utf8JsonReaderOneOf.CurrentDepth) + break; + + if (utf8JsonReaderOneOf.TokenType == JsonTokenType.PropertyName && currentDepth == utf8JsonReaderOneOf.CurrentDepth - 1) + { + Utf8JsonReader utf8JsonReaderString = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderString, jsonSerializerOptions, out varString); + + Utf8JsonReader utf8JsonReaderBool = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool); + + Utf8JsonReader utf8JsonReaderInt = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt); + + Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal); + + Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader; + ClientUtils.TryDeserialize(ref utf8JsonReaderMixedSubId, jsonSerializerOptions, out mixedSubId); + } + } + + 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) + { + default: + break; + } + } + } + + if (varString != null) + return new MixedOneOfContent(varString); + + if (varBool != null) + return new MixedOneOfContent(varBool.Value); + + if (varInt != null) + return new MixedOneOfContent(varInt.Value); + + if (varDecimal != null) + return new MixedOneOfContent(varDecimal.Value); + + if (mixedSubId != null) + return new MixedOneOfContent(mixedSubId); + + throw new JsonException(); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions) + { + + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..9766a9f410eb --- /dev/null +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,174 @@ +// +/* + * 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 +{ + /// + /// MixedSubId + /// + public partial class MixedSubId : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id + [JsonConstructor] + public MixedSubId(Option id = default) + { + IdOption = id; + OnCreated(); + } + + partial void OnCreated(); + + /// + /// Used to track the state of Id + /// + [JsonIgnore] + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Option IdOption { get; private set; } + + /// + /// Gets or Sets Id + /// + [JsonPropertyName("id")] + public string Id { get { return this.IdOption; } set { this.IdOption = 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubIdJsonConverter : JsonConverter + { + /// + /// Deserializes json to + /// + /// + /// + /// + /// + /// + public override MixedSubId 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 id = 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 "id": + id = new Option(utf8JsonReader.GetString()); + break; + default: + break; + } + } + } + + if (id.IsSet && id.Value == null) + throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId."); + + return new MixedSubId(id); + } + + /// + /// Serializes a + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + WriteProperties(writer, mixedSubId, jsonSerializerOptions); + writer.WriteEndObject(); + } + + /// + /// Serializes the properties of + /// + /// + /// + /// + /// + public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions) + { + if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null) + throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId."); + + if (mixedSubId.IdOption.IsSet) + writer.WriteString("id", mixedSubId.Id); + } + } +} diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs index 10061a2c228b..48dabfec1544 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/NullableShape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, NullableShape nullableShape, J { writer.WriteStartObject(); - if (nullableShape.Triangle != null) { + if (nullableShape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, nullableShape.Triangle, jsonSerializerOptions); } - if (nullableShape.Quadrilateral != null) { + if (nullableShape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(nullableShape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, nullableShape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs index 19e395f1de47..20323876ffc3 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Pig.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Pig pig, JsonSerializerOptions { writer.WriteStartObject(); - if (pig.BasquePig != null) { + if (pig.BasquePig != null) + { BasquePigJsonConverter basquePigJsonConverter = (BasquePigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.BasquePig.GetType())); basquePigJsonConverter.WriteProperties(writer, pig.BasquePig, jsonSerializerOptions); } - if (pig.DanishPig != null) { + if (pig.DanishPig != null) + { DanishPigJsonConverter danishPigJsonConverter = (DanishPigJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(pig.DanishPig.GetType())); danishPigJsonConverter.WriteProperties(writer, pig.DanishPig, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs index 3d333d7958fb..28fc8e1d46ec 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Quadrilateral.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Quadrilateral quadrilateral, J { writer.WriteStartObject(); - if (quadrilateral.SimpleQuadrilateral != null) { + if (quadrilateral.SimpleQuadrilateral != null) + { SimpleQuadrilateralJsonConverter simpleQuadrilateralJsonConverter = (SimpleQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.SimpleQuadrilateral.GetType())); simpleQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.SimpleQuadrilateral, jsonSerializerOptions); } - if (quadrilateral.ComplexQuadrilateral != null) { + if (quadrilateral.ComplexQuadrilateral != null) + { ComplexQuadrilateralJsonConverter complexQuadrilateralJsonConverter = (ComplexQuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(quadrilateral.ComplexQuadrilateral.GetType())); complexQuadrilateralJsonConverter.WriteProperties(writer, quadrilateral.ComplexQuadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs index d4883a363a21..d6710bed609c 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Shape.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, Shape shape, JsonSerializerOpt { writer.WriteStartObject(); - if (shape.Triangle != null) { + if (shape.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shape.Triangle, jsonSerializerOptions); } - if (shape.Quadrilateral != null) { + if (shape.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shape.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shape.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs index 2d9fb2cbb334..03781409be7d 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/ShapeOrNull.cs @@ -208,12 +208,14 @@ public override void Write(Utf8JsonWriter writer, ShapeOrNull shapeOrNull, JsonS { writer.WriteStartObject(); - if (shapeOrNull.Triangle != null) { + if (shapeOrNull.Triangle != null) + { TriangleJsonConverter triangleJsonConverter = (TriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Triangle.GetType())); triangleJsonConverter.WriteProperties(writer, shapeOrNull.Triangle, jsonSerializerOptions); } - if (shapeOrNull.Quadrilateral != null) { + if (shapeOrNull.Quadrilateral != null) + { QuadrilateralJsonConverter quadrilateralJsonConverter = (QuadrilateralJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(shapeOrNull.Quadrilateral.GetType())); quadrilateralJsonConverter.WriteProperties(writer, shapeOrNull.Quadrilateral, jsonSerializerOptions); } diff --git a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs index d31d2948c652..9c9fee0db0b6 100644 --- a/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs +++ b/samples/client/petstore/csharp/generichost/standard2.0/Petstore/src/Org.OpenAPITools/Model/Triangle.cs @@ -232,17 +232,20 @@ public override void Write(Utf8JsonWriter writer, Triangle triangle, JsonSeriali { writer.WriteStartObject(); - if (triangle.EquilateralTriangle != null) { + if (triangle.EquilateralTriangle != null) + { EquilateralTriangleJsonConverter equilateralTriangleJsonConverter = (EquilateralTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.EquilateralTriangle.GetType())); equilateralTriangleJsonConverter.WriteProperties(writer, triangle.EquilateralTriangle, jsonSerializerOptions); } - if (triangle.IsoscelesTriangle != null) { + if (triangle.IsoscelesTriangle != null) + { IsoscelesTriangleJsonConverter isoscelesTriangleJsonConverter = (IsoscelesTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.IsoscelesTriangle.GetType())); isoscelesTriangleJsonConverter.WriteProperties(writer, triangle.IsoscelesTriangle, jsonSerializerOptions); } - if (triangle.ScaleneTriangle != null) { + if (triangle.ScaleneTriangle != null) + { ScaleneTriangleJsonConverter scaleneTriangleJsonConverter = (ScaleneTriangleJsonConverter) jsonSerializerOptions.Converters.First(c => c.CanConvert(triangle.ScaleneTriangle.GetType())); scaleneTriangleJsonConverter.WriteProperties(writer, triangle.ScaleneTriangle, jsonSerializerOptions); } 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 1eeeb080e6f8..8ad42be271f2 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 @@ -52,7 +52,12 @@ docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md docs/MixLog.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -173,7 +178,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 5909e6fd5363..3a6aefa40046 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/README.md @@ -141,6 +141,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](docs/FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](docs/FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](docs/FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](docs/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -225,7 +227,12 @@ Class | Method | HTTP request | Description - [Model.Mammal](docs/Mammal.md) - [Model.MapTest](docs/MapTest.md) - [Model.MixLog](docs/MixLog.md) + - [Model.MixedAnyOf](docs/MixedAnyOf.md) + - [Model.MixedAnyOfContent](docs/MixedAnyOfContent.md) + - [Model.MixedOneOf](docs/MixedOneOf.md) + - [Model.MixedOneOfContent](docs/MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](docs/MixedSubId.md) - [Model.Model200Response](docs/Model200Response.md) - [Model.ModelClient](docs/ModelClient.md) - [Model.Name](docs/Name.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 e4713d2621c4..f772773afefa 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 @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/FakeApi.md b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/FakeApi.md index 754a08ec0278..bedc98a6492a 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/FakeApi.md +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -573,6 +575,182 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using System.Net.Http; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using System.Net.Http; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes + HttpClient httpClient = new HttpClient(); + HttpClientHandler httpClientHandler = new HttpClientHandler(); + var apiInstance = new FakeApi(httpClient, config, httpClientHandler); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 84983f84495e..93f2fed80098 100644 --- a/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -146,6 +146,38 @@ public interface IFakeApiSync : IApiAccessor /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// MixedOneOf + MixedOneOf GetMixedOneOf(); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -595,6 +627,48 @@ public interface IFakeApiAsync : IApiAccessor /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1797,6 +1871,208 @@ public Org.OpenAPITools.Client.ApiResponse> GetArrayOfEnumsWithH return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf() + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo() + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedAnyOfWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// MixedOneOf + public MixedOneOf GetMixedOneOf() + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo() + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedOneOfWithHttpInfoAsync(cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + /// /// test referenced additionalProperties /// diff --git a/samples/client/petstore/csharp/restsharp/net7/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/restsharp/net7/Petstore/.openapi-generator/FILES index e918fe156009..1149d7663f8f 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/.openapi-generator/FILES @@ -52,7 +52,12 @@ docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md docs/MixLog.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -175,7 +180,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.cs diff --git a/samples/client/petstore/csharp/restsharp/net7/Petstore/README.md b/samples/client/petstore/csharp/restsharp/net7/Petstore/README.md index 871fe017f80b..665228c99cbc 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/README.md +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/README.md @@ -128,6 +128,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](docs/FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](docs/FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](docs/FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](docs/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -212,7 +214,12 @@ Class | Method | HTTP request | Description - [Model.Mammal](docs/Mammal.md) - [Model.MapTest](docs/MapTest.md) - [Model.MixLog](docs/MixLog.md) + - [Model.MixedAnyOf](docs/MixedAnyOf.md) + - [Model.MixedAnyOfContent](docs/MixedAnyOfContent.md) + - [Model.MixedOneOf](docs/MixedOneOf.md) + - [Model.MixedOneOfContent](docs/MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](docs/MixedSubId.md) - [Model.Model200Response](docs/Model200Response.md) - [Model.ModelClient](docs/ModelClient.md) - [Model.Name](docs/Name.md) diff --git a/samples/client/petstore/csharp/restsharp/net7/Petstore/api/openapi.yaml b/samples/client/petstore/csharp/restsharp/net7/Petstore/api/openapi.yaml index e4713d2621c4..f772773afefa 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/api/openapi.yaml +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/api/openapi.yaml @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/restsharp/net7/Petstore/docs/FakeApi.md b/samples/client/petstore/csharp/restsharp/net7/Petstore/docs/FakeApi.md index 788c4017bba8..933fb1c7cad3 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/docs/FakeApi.md +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index fda76f972ea2..d2863e79474b 100644 --- a/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/restsharp/net7/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -158,6 +158,42 @@ public interface IFakeApiSync : IApiAccessor /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(int operationIndex = 0); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(int operationIndex = 0); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + MixedOneOf GetMixedOneOf(int operationIndex = 0); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -643,6 +679,52 @@ public interface IFakeApiAsync : IApiAccessor /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1926,6 +2008,258 @@ public Org.OpenAPITools.Client.ApiResponse> GetArrayOfEnumsWithH return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedAnyOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + public MixedOneOf GetMixedOneOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedOneOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + /// /// test referenced additionalProperties /// 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 afe863b77d71..2a5dbfbe6e6f 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 @@ -52,7 +52,12 @@ docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md docs/MixLog.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -176,7 +181,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 50b51107eb12..340cefd90979 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/README.md @@ -116,6 +116,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](docs/FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](docs/FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](docs/FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](docs/FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](docs/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](docs/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -200,7 +202,12 @@ Class | Method | HTTP request | Description - [Model.Mammal](docs/Mammal.md) - [Model.MapTest](docs/MapTest.md) - [Model.MixLog](docs/MixLog.md) + - [Model.MixedAnyOf](docs/MixedAnyOf.md) + - [Model.MixedAnyOfContent](docs/MixedAnyOfContent.md) + - [Model.MixedOneOf](docs/MixedOneOf.md) + - [Model.MixedOneOfContent](docs/MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](docs/MixedSubId.md) - [Model.Model200Response](docs/Model200Response.md) - [Model.ModelClient](docs/ModelClient.md) - [Model.Name](docs/Name.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 e4713d2621c4..f772773afefa 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 @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/FakeApi.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/FakeApi.md index 356154a4b991..06309f31e8a5 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/FakeApi.md +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedAnyOf.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedAnyOf.md new file mode 100644 index 000000000000..6a6aa093bebe --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedAnyOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedAnyOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedAnyOfContent**](MixedAnyOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedAnyOfContent.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedAnyOfContent.md new file mode 100644 index 000000000000..9af972f3219f --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedAnyOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedAnyOfContent +Mixed anyOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/MixedOneOf.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedOneOf.md new file mode 100644 index 000000000000..dc9650a8e3a0 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedOneOf.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedOneOf + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Content** | [**MixedOneOfContent**](MixedOneOfContent.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedOneOfContent.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedOneOfContent.md new file mode 100644 index 000000000000..8468f9024f73 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedOneOfContent.md @@ -0,0 +1,11 @@ +# Org.OpenAPITools.Model.MixedOneOfContent +Mixed oneOf types for testing + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/MixedSubId.md b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedSubId.md new file mode 100644 index 000000000000..b9268e37cba6 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/docs/MixedSubId.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.MixedSubId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | | [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/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs new file mode 100644 index 000000000000..ab5a04a36329 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedAnyOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using 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 MixedAnyOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOfContent + //private MixedAnyOfContent instance; + + public MixedAnyOfContentTests() + { + // TODO uncomment below to create an instance of MixedAnyOfContent + //instance = new MixedAnyOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOfContent + /// + [Fact] + public void MixedAnyOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs new file mode 100644 index 000000000000..9cddd4adcb08 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedAnyOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using 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 MixedAnyOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedAnyOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedAnyOf + //private MixedAnyOf instance; + + public MixedAnyOfTests() + { + // TODO uncomment below to create an instance of MixedAnyOf + //instance = new MixedAnyOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedAnyOf + /// + [Fact] + public void MixedAnyOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedAnyOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs new file mode 100644 index 000000000000..4d4a29901c80 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedOneOfContentTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using 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 MixedOneOfContent + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfContentTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOfContent + //private MixedOneOfContent instance; + + public MixedOneOfContentTests() + { + // TODO uncomment below to create an instance of MixedOneOfContent + //instance = new MixedOneOfContent(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOfContent + /// + [Fact] + public void MixedOneOfContentInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOfContent + //Assert.IsType(instance); + } + + /// + /// Test the property 'Id' + /// + [Fact] + public void IdTest() + { + // TODO unit test for the property 'Id' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs new file mode 100644 index 000000000000..4be8482614de --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools.Test/Model/MixedOneOfTests.cs @@ -0,0 +1,66 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using 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 MixedOneOf + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class MixedOneOfTests : IDisposable + { + // TODO uncomment below to declare an instance variable for MixedOneOf + //private MixedOneOf instance; + + public MixedOneOfTests() + { + // TODO uncomment below to create an instance of MixedOneOf + //instance = new MixedOneOf(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of MixedOneOf + /// + [Fact] + public void MixedOneOfInstanceTest() + { + // TODO uncomment below to test "IsType" MixedOneOf + //Assert.IsType(instance); + } + + /// + /// Test the property 'Content' + /// + [Fact] + public void ContentTest() + { + // TODO unit test for the property 'Content' + } + } +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/FakeApi.cs index bc6276012d1e..82d3054c5a90 100644 --- a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Api/FakeApi.cs @@ -158,6 +158,42 @@ public interface IFakeApiSync : IApiAccessor /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(int operationIndex = 0); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(int operationIndex = 0); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + MixedOneOf GetMixedOneOf(int operationIndex = 0); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -643,6 +679,52 @@ public interface IFakeApiAsync : IApiAccessor /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1926,6 +2008,258 @@ public Org.OpenAPITools.Client.ApiResponse> GetArrayOfEnumsWithH return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedAnyOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedAnyOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// MixedOneOf + public MixedOneOf GetMixedOneOf(int operationIndex = 0) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo(int operationIndex = 0) + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = await GetMixedOneOfWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + + + localVarRequestOptions.Operation = "FakeApi.GetMixedOneOf"; + localVarRequestOptions.OperationIndex = operationIndex; + + + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + + return localVarResponse; + } + /// /// test referenced additionalProperties /// diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedAnyOf.cs new file mode 100644 index 000000000000..266f472b481a --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedAnyOf.cs @@ -0,0 +1,154 @@ +/* + * 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 +{ + /// + /// MixedAnyOf + /// + [DataContract(Name = "MixedAnyOf")] + public partial class MixedAnyOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedAnyOf(MixedAnyOfContent content = default(MixedAnyOfContent)) + { + this._Content = content; + if (this.Content != null) + { + this._flagContent = true; + } + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedAnyOfContent Content + { + get{ return _Content;} + set + { + _Content = value; + _flagContent = true; + } + } + private MixedAnyOfContent _Content; + private bool _flagContent; + + /// + /// Returns false as Content should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeContent() + { + return _flagContent; + } + /// + /// 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 MixedAnyOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedAnyOf).AreEqual; + } + + /// + /// Returns true if MixedAnyOf instances are equal + /// + /// Instance of MixedAnyOf to be compared + /// Boolean + public bool Equals(MixedAnyOf 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.Content != null) + { + hashCode = (hashCode * 59) + this.Content.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/MixedAnyOfContent.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs new file mode 100644 index 000000000000..a81b6df04193 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedAnyOfContent.cs @@ -0,0 +1,390 @@ +/* + * 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; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed anyOf types for testing + /// + [JsonConverter(typeof(MixedAnyOfContentJsonConverter))] + [DataContract(Name = "MixedAnyOf_content")] + public partial class MixedAnyOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedAnyOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedAnyOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedAnyOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedAnyOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedAnyOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "anyOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedAnyOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedAnyOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedAnyOfContent + /// + /// JSON string + /// An instance of MixedAnyOfContent + public static MixedAnyOfContent FromJson(string jsonString) + { + MixedAnyOfContent newMixedAnyOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedAnyOfContent; + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + newMixedAnyOfContent = new MixedAnyOfContent(JsonConvert.DeserializeObject(jsonString, MixedAnyOfContent.SerializerSettings)); + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedAnyOfContent; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + // no match found, throw an exception + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedAnyOfContent).AreEqual; + } + + /// + /// Returns true if MixedAnyOfContent instances are equal + /// + /// Instance of MixedAnyOfContent to be compared + /// Boolean + public bool Equals(MixedAnyOfContent 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.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedAnyOfContent + /// + public class MixedAnyOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedAnyOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedAnyOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedAnyOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedAnyOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedAnyOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedAnyOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedAnyOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedOneOf.cs new file mode 100644 index 000000000000..ba459fc807f7 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedOneOf.cs @@ -0,0 +1,154 @@ +/* + * 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 +{ + /// + /// MixedOneOf + /// + [DataContract(Name = "MixedOneOf")] + public partial class MixedOneOf : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// content. + public MixedOneOf(MixedOneOfContent content = default(MixedOneOfContent)) + { + this._Content = content; + if (this.Content != null) + { + this._flagContent = true; + } + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Content + /// + [DataMember(Name = "content", EmitDefaultValue = false)] + public MixedOneOfContent Content + { + get{ return _Content;} + set + { + _Content = value; + _flagContent = true; + } + } + private MixedOneOfContent _Content; + private bool _flagContent; + + /// + /// Returns false as Content should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeContent() + { + return _flagContent; + } + /// + /// 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 MixedOneOf {\n"); + sb.Append(" Content: ").Append(Content).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 MixedOneOf).AreEqual; + } + + /// + /// Returns true if MixedOneOf instances are equal + /// + /// Instance of MixedOneOf to be compared + /// Boolean + public bool Equals(MixedOneOf 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.Content != null) + { + hashCode = (hashCode * 59) + this.Content.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/MixedOneOfContent.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedOneOfContent.cs new file mode 100644 index 000000000000..83fe641b56ae --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedOneOfContent.cs @@ -0,0 +1,441 @@ +/* + * 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; +using System.Reflection; + +namespace Org.OpenAPITools.Model +{ + /// + /// Mixed oneOf types for testing + /// + [JsonConverter(typeof(MixedOneOfContentJsonConverter))] + [DataContract(Name = "MixedOneOf_content")] + public partial class MixedOneOfContent : AbstractOpenAPISchema, IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of string. + public MixedOneOfContent(string actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of bool. + public MixedOneOfContent(bool actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of int. + public MixedOneOfContent(int actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of decimal. + public MixedOneOfContent(decimal actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance; + } + + /// + /// Initializes a new instance of the class + /// with the class + /// + /// An instance of MixedSubId. + public MixedOneOfContent(MixedSubId actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(MixedSubId)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(bool)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(decimal)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(int)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(string)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: MixedSubId, bool, decimal, int, string"); + } + } + } + + /// + /// Get the actual instance of `string`. If the actual instance is not `string`, + /// the InvalidClassException will be thrown + /// + /// An instance of string + public string GetString() + { + return (string)this.ActualInstance; + } + + /// + /// Get the actual instance of `bool`. If the actual instance is not `bool`, + /// the InvalidClassException will be thrown + /// + /// An instance of bool + public bool GetBool() + { + return (bool)this.ActualInstance; + } + + /// + /// Get the actual instance of `int`. If the actual instance is not `int`, + /// the InvalidClassException will be thrown + /// + /// An instance of int + public int GetInt() + { + return (int)this.ActualInstance; + } + + /// + /// Get the actual instance of `decimal`. If the actual instance is not `decimal`, + /// the InvalidClassException will be thrown + /// + /// An instance of decimal + public decimal GetDecimal() + { + return (decimal)this.ActualInstance; + } + + /// + /// Get the actual instance of `MixedSubId`. If the actual instance is not `MixedSubId`, + /// the InvalidClassException will be thrown + /// + /// An instance of MixedSubId + public MixedSubId GetMixedSubId() + { + return (MixedSubId)this.ActualInstance; + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class MixedOneOfContent {\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override string ToJson() + { + return JsonConvert.SerializeObject(this.ActualInstance, MixedOneOfContent.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of MixedOneOfContent + /// + /// JSON string + /// An instance of MixedOneOfContent + public static MixedOneOfContent FromJson(string jsonString) + { + MixedOneOfContent newMixedOneOfContent = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newMixedOneOfContent; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(MixedSubId).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("MixedSubId"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into MixedSubId: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(bool).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("bool"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into bool: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(decimal).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("decimal"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into decimal: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(int).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("int"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into int: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(string).GetProperty("AdditionalProperties") == null) + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.SerializerSettings)); + } + else + { + newMixedOneOfContent = new MixedOneOfContent(JsonConvert.DeserializeObject(jsonString, MixedOneOfContent.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("string"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into string: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + String.Join(",", matchedTypes)); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newMixedOneOfContent; + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as MixedOneOfContent).AreEqual; + } + + /// + /// Returns true if MixedOneOfContent instances are equal + /// + /// Instance of MixedOneOfContent to be compared + /// Boolean + public bool Equals(MixedOneOfContent 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.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// Custom JSON converter for MixedOneOfContent + /// + public class MixedOneOfContentJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(MixedOneOfContent).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + switch(reader.TokenType) + { + case JsonToken.String: + return new MixedOneOfContent(Convert.ToString(reader.Value)); + case JsonToken.Boolean: + return new MixedOneOfContent(Convert.ToBoolean(reader.Value)); + case JsonToken.Integer: + return new MixedOneOfContent(Convert.ToInt32(reader.Value)); + case JsonToken.Float: + return new MixedOneOfContent(Convert.ToDecimal(reader.Value)); + case JsonToken.StartObject: + return MixedOneOfContent.FromJson(JObject.Load(reader).ToString(Formatting.None)); + case JsonToken.StartArray: + return MixedOneOfContent.FromJson(JArray.Load(reader).ToString(Formatting.None)); + default: + return null; + } + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + +} diff --git a/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedSubId.cs new file mode 100644 index 000000000000..7e04f85cdd24 --- /dev/null +++ b/samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Model/MixedSubId.cs @@ -0,0 +1,154 @@ +/* + * 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 +{ + /// + /// MixedSubId + /// + [DataContract(Name = "MixedSubId")] + public partial class MixedSubId : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// id. + public MixedSubId(string id = default(string)) + { + this._Id = id; + if (this.Id != null) + { + this._flagId = true; + } + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = false)] + public string Id + { + get{ return _Id;} + set + { + _Id = value; + _flagId = true; + } + } + private string _Id; + private bool _flagId; + + /// + /// Returns false as Id should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeId() + { + return _flagId; + } + /// + /// 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 MixedSubId {\n"); + sb.Append(" Id: ").Append(Id).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 MixedSubId).AreEqual; + } + + /// + /// Returns true if MixedSubId instances are equal + /// + /// Instance of MixedSubId to be compared + /// Boolean + public bool Equals(MixedSubId 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.Id != null) + { + hashCode = (hashCode * 59) + this.Id.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/unityWebRequest/standard2.0/Petstore/.openapi-generator/FILES b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/.openapi-generator/FILES index 2b84fd7b3a08..a465aeaf1e0d 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 @@ -50,7 +50,12 @@ docs/LiteralStringClass.md docs/Mammal.md docs/MapTest.md docs/MixLog.md +docs/MixedAnyOf.md +docs/MixedAnyOfContent.md +docs/MixedOneOf.md +docs/MixedOneOfContent.md docs/MixedPropertiesAndAdditionalPropertiesClass.md +docs/MixedSubId.md docs/Model200Response.md docs/ModelClient.md docs/Name.md @@ -172,7 +177,12 @@ src/Org.OpenAPITools/Model/LiteralStringClass.cs src/Org.OpenAPITools/Model/Mammal.cs src/Org.OpenAPITools/Model/MapTest.cs src/Org.OpenAPITools/Model/MixLog.cs +src/Org.OpenAPITools/Model/MixedAnyOf.cs +src/Org.OpenAPITools/Model/MixedAnyOfContent.cs +src/Org.OpenAPITools/Model/MixedOneOf.cs +src/Org.OpenAPITools/Model/MixedOneOfContent.cs src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs +src/Org.OpenAPITools/Model/MixedSubId.cs src/Org.OpenAPITools/Model/Model200Response.cs src/Org.OpenAPITools/Model/ModelClient.cs src/Org.OpenAPITools/Model/Name.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 46ffd149a6f6..1ec123ad7a77 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/README.md @@ -102,6 +102,8 @@ Class | Method | HTTP request | Description *FakeApi* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | *FakeApi* | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums +*FakeApi* | [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization +*FakeApi* | [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization *FakeApi* | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties *FakeApi* | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | *FakeApi* | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | @@ -186,7 +188,12 @@ Class | Method | HTTP request | Description - [Model.Mammal](Mammal.md) - [Model.MapTest](MapTest.md) - [Model.MixLog](MixLog.md) + - [Model.MixedAnyOf](MixedAnyOf.md) + - [Model.MixedAnyOfContent](MixedAnyOfContent.md) + - [Model.MixedOneOf](MixedOneOf.md) + - [Model.MixedOneOfContent](MixedOneOfContent.md) - [Model.MixedPropertiesAndAdditionalPropertiesClass](MixedPropertiesAndAdditionalPropertiesClass.md) + - [Model.MixedSubId](MixedSubId.md) - [Model.Model200Response](Model200Response.md) - [Model.ModelClient](ModelClient.md) - [Model.Name](Name.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 e4713d2621c4..f772773afefa 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 @@ -1213,6 +1213,32 @@ paths: summary: Array of Enums tags: - fake + /fake/mixed/anyOf: + get: + operationId: getMixedAnyOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedAnyOf' + description: Got mixed anyOf + summary: Test mixed type anyOf deserialization + tags: + - fake + /fake/mixed/oneOf: + get: + operationId: getMixedOneOf + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/MixedOneOf' + description: Got mixed oneOf + summary: Test mixed type oneOf deserialization + tags: + - fake /country: post: operationId: getCountry @@ -2706,6 +2732,22 @@ components: - a_objVariableobject - pkiNotificationtestID type: object + MixedOneOf: + example: + content: MixedOneOf_content + properties: + content: + $ref: '#/components/schemas/MixedOneOf_content' + MixedAnyOf: + example: + content: MixedAnyOf_content + properties: + content: + $ref: '#/components/schemas/MixedAnyOf_content' + MixedSubId: + properties: + id: + type: string MixLog: properties: id: @@ -2974,6 +3016,26 @@ components: name: type: string type: object + MixedOneOf_content: + description: Mixed oneOf types for testing + oneOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + MixedAnyOf_content: + anyOf: + - type: string + - type: boolean + - format: uint8 + type: integer + - format: float32 + type: number + - $ref: '#/components/schemas/MixedSubId' + description: Mixed anyOf types for testing securitySchemes: petstore_auth: flows: diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/FakeApi.md b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/FakeApi.md index 356154a4b991..06309f31e8a5 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/FakeApi.md +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/docs/FakeApi.md @@ -10,6 +10,8 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* | [**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | | | [**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | | | [**GetArrayOfEnums**](FakeApi.md#getarrayofenums) | **GET** /fake/array-of-enums | Array of Enums | +| [**GetMixedAnyOf**](FakeApi.md#getmixedanyof) | **GET** /fake/mixed/anyOf | Test mixed type anyOf deserialization | +| [**GetMixedOneOf**](FakeApi.md#getmixedoneof) | **GET** /fake/mixed/oneOf | Test mixed type oneOf deserialization | | [**TestAdditionalPropertiesReference**](FakeApi.md#testadditionalpropertiesreference) | **POST** /fake/additionalProperties-reference | test referenced additionalProperties | | [**TestBodyWithFileSchema**](FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema | | | [**TestBodyWithQueryParams**](FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params | | @@ -549,6 +551,174 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **GetMixedAnyOf** +> MixedAnyOf GetMixedAnyOf () + +Test mixed type anyOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedAnyOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type anyOf deserialization + MixedAnyOf result = apiInstance.GetMixedAnyOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedAnyOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedAnyOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type anyOf deserialization + ApiResponse response = apiInstance.GetMixedAnyOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedAnyOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedAnyOf**](MixedAnyOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed anyOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **GetMixedOneOf** +> MixedOneOf GetMixedOneOf () + +Test mixed type oneOf deserialization + +### Example +```csharp +using System.Collections.Generic; +using System.Diagnostics; +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Client; +using Org.OpenAPITools.Model; + +namespace Example +{ + public class GetMixedOneOfExample + { + public static void Main() + { + Configuration config = new Configuration(); + config.BasePath = "http://petstore.swagger.io:80/v2"; + var apiInstance = new FakeApi(config); + + try + { + // Test mixed type oneOf deserialization + MixedOneOf result = apiInstance.GetMixedOneOf(); + Debug.WriteLine(result); + } + catch (ApiException e) + { + Debug.Print("Exception when calling FakeApi.GetMixedOneOf: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); + } + } + } +} +``` + +#### Using the GetMixedOneOfWithHttpInfo variant +This returns an ApiResponse object which contains the response data, status code and headers. + +```csharp +try +{ + // Test mixed type oneOf deserialization + ApiResponse response = apiInstance.GetMixedOneOfWithHttpInfo(); + Debug.Write("Status Code: " + response.StatusCode); + Debug.Write("Response Headers: " + response.Headers); + Debug.Write("Response Body: " + response.Data); +} +catch (ApiException e) +{ + Debug.Print("Exception when calling FakeApi.GetMixedOneOfWithHttpInfo: " + e.Message); + Debug.Print("Status Code: " + e.ErrorCode); + Debug.Print(e.StackTrace); +} +``` + +### Parameters +This endpoint does not need any parameter. +### Return type + +[**MixedOneOf**](MixedOneOf.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Got mixed oneOf | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestAdditionalPropertiesReference** > void TestAdditionalPropertiesReference (Dictionary requestBody) diff --git a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs index 4f6ee8fad052..59ce0a9e7b12 100644 --- a/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/unityWebRequest/standard2.0/Petstore/src/Org.OpenAPITools/Api/FakeApi.cs @@ -145,6 +145,38 @@ public interface IFakeApiSync : IApiAccessor /// ApiResponse of List<OuterEnum> ApiResponse> GetArrayOfEnumsWithHttpInfo(); /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// MixedAnyOf + MixedAnyOf GetMixedAnyOf(); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedAnyOf + ApiResponse GetMixedAnyOfWithHttpInfo(); + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// MixedOneOf + MixedOneOf GetMixedOneOf(); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedOneOf + ApiResponse GetMixedOneOfWithHttpInfo(); + /// /// test referenced additionalProperties /// /// Thrown when fails to make API call @@ -594,6 +626,48 @@ public interface IFakeApiAsync : IApiAccessor /// Task of ApiResponse (List<OuterEnum>) System.Threading.Tasks.Task>> GetArrayOfEnumsWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + System.Threading.Tasks.Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type anyOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + System.Threading.Tasks.Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Test mixed type oneOf deserialization + /// + /// + /// + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// test referenced additionalProperties /// /// @@ -1793,6 +1867,230 @@ public Org.OpenAPITools.Client.ApiResponse> GetArrayOfEnumsWithH return localVarResponse; } + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// MixedAnyOf + public MixedAnyOf GetMixedAnyOf() + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedAnyOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedAnyOf + public Org.OpenAPITools.Client.ApiResponse GetMixedAnyOfWithHttpInfo() + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedAnyOf + public async System.Threading.Tasks.Task GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + var task = GetMixedAnyOfWithHttpInfoAsync(cancellationToken); +#if UNITY_EDITOR || !UNITY_WEBGL + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task.ConfigureAwait(false); +#else + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task; +#endif + return localVarResponse.Data; + } + + /// + /// Test mixed type anyOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedAnyOf) + public async System.Threading.Tasks.Task> GetMixedAnyOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + + var task = this.AsynchronousClient.GetAsync("/fake/mixed/anyOf", localVarRequestOptions, this.Configuration, cancellationToken); + +#if UNITY_EDITOR || !UNITY_WEBGL + var localVarResponse = await task.ConfigureAwait(false); +#else + var localVarResponse = await task; +#endif + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedAnyOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// MixedOneOf + public MixedOneOf GetMixedOneOf() + { + Org.OpenAPITools.Client.ApiResponse localVarResponse = GetMixedOneOfWithHttpInfo(); + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// ApiResponse of MixedOneOf + public Org.OpenAPITools.Client.ApiResponse GetMixedOneOfWithHttpInfo() + { + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + var localVarResponse = this.Client.Get("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of MixedOneOf + public async System.Threading.Tasks.Task GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + var task = GetMixedOneOfWithHttpInfoAsync(cancellationToken); +#if UNITY_EDITOR || !UNITY_WEBGL + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task.ConfigureAwait(false); +#else + Org.OpenAPITools.Client.ApiResponse localVarResponse = await task; +#endif + return localVarResponse.Data; + } + + /// + /// Test mixed type oneOf deserialization + /// + /// Thrown when fails to make API call + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (MixedOneOf) + public async System.Threading.Tasks.Task> GetMixedOneOfWithHttpInfoAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + + Org.OpenAPITools.Client.RequestOptions localVarRequestOptions = new Org.OpenAPITools.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = Org.OpenAPITools.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = Org.OpenAPITools.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + + + // make the HTTP request + + var task = this.AsynchronousClient.GetAsync("/fake/mixed/oneOf", localVarRequestOptions, this.Configuration, cancellationToken); + +#if UNITY_EDITOR || !UNITY_WEBGL + var localVarResponse = await task.ConfigureAwait(false); +#else + var localVarResponse = await task; +#endif + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("GetMixedOneOf", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + /// /// test referenced additionalProperties ///