[csharp][generichost] Add support for primitive composed (#18825)

* add support for primitive composed

* build samples again

* rebuild tests

* addressed comment
This commit is contained in:
devhl-labs 2024-06-04 00:38:53 -04:00 committed by GitHub
parent ed2aad6756
commit 91a1931bd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
289 changed files with 24035 additions and 145 deletions

View File

@ -603,6 +603,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
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 abstract class AbstractCSharpCodegen extends DefaultCodegen {
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));
}
}
}

View File

@ -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}}

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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)
<a id="getmixedanyof"></a>
# **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<MixedAnyOf> 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)
<a id="getmixedoneof"></a>
# **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<MixedOneOf> 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)
<a id="testadditionalpropertiesreference"></a>
# **TestAdditionalPropertiesReference**
> void TestAdditionalPropertiesReference (Dictionary<string, Object> requestBody)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -121,6 +121,28 @@ namespace Org.OpenAPITools.Test.Api
Assert.IsType<List<OuterEnum>>(model);
}
/// <summary>
/// Test GetMixedAnyOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedAnyOfAsyncTest()
{
var response = await _instance.GetMixedAnyOfAsync();
var model = response.Ok();
Assert.IsType<MixedAnyOf>(model);
}
/// <summary>
/// Test GetMixedOneOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedOneOfAsyncTest()
{
var response = await _instance.GetMixedOneOfAsync();
var model = response.Ok();
Assert.IsType<MixedOneOf>(model);
}
/// <summary>
/// Test TestAdditionalPropertiesReference
/// </summary>

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOfContent
/// </summary>
[Fact]
public void MixedAnyOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOfContent
//Assert.IsType<MixedAnyOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOf
/// </summary>
[Fact]
public void MixedAnyOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOf
//Assert.IsType<MixedAnyOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOfContent
/// </summary>
[Fact]
public void MixedOneOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOfContent
//Assert.IsType<MixedOneOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOf
/// </summary>
[Fact]
public void MixedOneOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOf
//Assert.IsType<MixedOneOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedSubId
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedSubId
/// </summary>
[Fact]
public void MixedSubIdInstanceTest()
{
// TODO uncomment below to test "IsType" MixedSubId
//Assert.IsType<MixedSubId>(instance);
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Fact]
public void IdTest()
{
// TODO unit test for the property 'Id'
}
}
}

View File

@ -169,6 +169,48 @@ namespace Org.OpenAPITools.Api
/// <returns><see cref="Task"/>&lt;<see cref="IGetArrayOfEnumsApiResponse"/>&gt;</returns>
Task<IGetArrayOfEnumsApiResponse> GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
Task<IGetMixedOneOfApiResponse> GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
Task<IGetMixedOneOfApiResponse> GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// test referenced additionalProperties
/// </summary>
@ -588,6 +630,30 @@ namespace Org.OpenAPITools.Api
bool IsOk { get; }
}
/// <summary>
/// The <see cref="IGetMixedAnyOfApiResponse"/>
/// </summary>
public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.MixedAnyOf>
{
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
bool IsOk { get; }
}
/// <summary>
/// The <see cref="IGetMixedOneOfApiResponse"/>
/// </summary>
public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.MixedOneOf>
{
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
bool IsOk { get; }
}
/// <summary>
/// The <see cref="ITestAdditionalPropertiesReferenceApiResponse"/>
/// </summary>
@ -869,6 +935,46 @@ namespace Org.OpenAPITools.Api
OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
public event EventHandler<ApiResponseEventArgs> OnGetMixedAnyOf;
/// <summary>
/// The event raised after an error querying the server
/// </summary>
public event EventHandler<ExceptionEventArgs> OnErrorGetMixedAnyOf;
internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse)
{
OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse));
}
internal void ExecuteOnErrorGetMixedAnyOf(Exception exception)
{
OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
public event EventHandler<ApiResponseEventArgs> OnGetMixedOneOf;
/// <summary>
/// The event raised after an error querying the server
/// </summary>
public event EventHandler<ExceptionEventArgs> OnErrorGetMixedOneOf;
internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse)
{
OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse));
}
internal void ExecuteOnErrorGetMixedOneOf(Exception exception)
{
OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
@ -2477,6 +2583,392 @@ namespace Org.OpenAPITools.Api
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="apiResponseLocalVar"></param>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="apiResponseLocalVar"></param>
partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar);
/// <summary>
/// Logs exceptions that occur while retrieving the server response
/// </summary>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
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.");
}
/// <summary>
/// A partial method that gives developers a way to provide customized exception handling
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedAnyOfApiResponse> 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<GetMixedAnyOfApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetMixedAnyOfApiResponse>();
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;
}
}
/// <summary>
/// The <see cref="GetMixedAnyOfApiResponse"/>
/// </summary>
public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse
{
/// <summary>
/// The logger
/// </summary>
public ILogger<GetMixedAnyOfApiResponse> Logger { get; }
/// <summary>
/// The <see cref="GetMixedAnyOfApiResponse"/>
/// </summary>
/// <param name="logger"></param>
/// <param name="httpRequestMessage"></param>
/// <param name="httpResponseMessage"></param>
/// <param name="rawContent"></param>
/// <param name="path"></param>
/// <param name="requestedAt"></param>
/// <param name="jsonSerializerOptions"></param>
public GetMixedAnyOfApiResponse(ILogger<GetMixedAnyOfApiResponse> 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);
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
public bool IsOk => 200 == (int)StatusCode;
/// <summary>
/// Deserializes the response if the response is 200 Ok
/// </summary>
/// <returns></returns>
public Org.OpenAPITools.Model.MixedAnyOf Ok()
{
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.MixedAnyOf>(RawContent, _jsonSerializerOptions)
: default;
}
/// <summary>
/// Returns true if the response is 200 Ok and the deserialized response is not null
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="apiResponseLocalVar"></param>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="apiResponseLocalVar"></param>
partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar);
/// <summary>
/// Logs exceptions that occur while retrieving the server response
/// </summary>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
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.");
}
/// <summary>
/// A partial method that gives developers a way to provide customized exception handling
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedOneOfApiResponse> GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedOneOfApiResponse> 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<GetMixedOneOfApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetMixedOneOfApiResponse>();
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;
}
}
/// <summary>
/// The <see cref="GetMixedOneOfApiResponse"/>
/// </summary>
public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse
{
/// <summary>
/// The logger
/// </summary>
public ILogger<GetMixedOneOfApiResponse> Logger { get; }
/// <summary>
/// The <see cref="GetMixedOneOfApiResponse"/>
/// </summary>
/// <param name="logger"></param>
/// <param name="httpRequestMessage"></param>
/// <param name="httpResponseMessage"></param>
/// <param name="rawContent"></param>
/// <param name="path"></param>
/// <param name="requestedAt"></param>
/// <param name="jsonSerializerOptions"></param>
public GetMixedOneOfApiResponse(ILogger<GetMixedOneOfApiResponse> 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);
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
public bool IsOk => 200 == (int)StatusCode;
/// <summary>
/// Deserializes the response if the response is 200 Ok
/// </summary>
/// <returns></returns>
public Org.OpenAPITools.Model.MixedOneOf Ok()
{
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.MixedOneOf>(RawContent, _jsonSerializerOptions)
: default;
}
/// <summary>
/// Returns true if the response is 200 Ok and the deserialized response is not null
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
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<string, Object> requestBody);
/// <summary>

View File

@ -101,7 +101,12 @@ namespace Org.OpenAPITools.Client
_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());

View File

@ -232,17 +232,20 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -0,0 +1,178 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedAnyOf
/// </summary>
public partial class MixedAnyOf : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedAnyOf" /> class.
/// </summary>
/// <param name="content">content</param>
[JsonConstructor]
public MixedAnyOf(Option<MixedAnyOfContent> content = default)
{
ContentOption = content;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Content
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedAnyOfContent> ContentOption { get; private set; }
/// <summary>
/// Gets or Sets Content
/// </summary>
[JsonPropertyName("content")]
public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = new Option<MixedAnyOfContent>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedAnyOf" />
/// </summary>
public class MixedAnyOfJsonConverter : JsonConverter<MixedAnyOf>
{
/// <summary>
/// Deserializes json to <see cref="MixedAnyOf" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<MixedAnyOfContent> 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<MixedAnyOfContent>(JsonSerializer.Deserialize<MixedAnyOfContent>(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);
}
/// <summary>
/// Serializes a <see cref="MixedAnyOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedAnyOf, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedAnyOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}
}

View File

@ -0,0 +1,283 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// Mixed anyOf types for testing
/// </summary>
public partial class MixedAnyOfContent : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedAnyOfContent" /> class.
/// </summary>
/// <param name="string"></param>
/// <param name="bool"></param>
/// <param name="int"></param>
/// <param name="decimal"></param>
/// <param name="mixedSubId"></param>
public MixedAnyOfContent(Option<string> @string, Option<bool?> @bool, Option<int?> @int, Option<decimal?> @decimal, Option<MixedSubId> mixedSubId)
{
StringOption = @string;
BoolOption = @bool;
IntOption = @int;
DecimalOption = @decimal;
MixedSubIdOption = mixedSubId;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of String
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<string> StringOption { get; private set; }
/// <summary>
/// Gets or Sets String
/// </summary>
public string String { get { return this.StringOption; } set { this.StringOption = new Option<string>(value); } }
/// <summary>
/// Used to track the state of Bool
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<bool?> BoolOption { get; private set; }
/// <summary>
/// Gets or Sets Bool
/// </summary>
public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option<bool?>(value); } }
/// <summary>
/// Used to track the state of Int
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<int?> IntOption { get; private set; }
/// <summary>
/// Gets or Sets Int
/// </summary>
public int? Int { get { return this.IntOption; } set { this.IntOption = new Option<int?>(value); } }
/// <summary>
/// Used to track the state of Decimal
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<decimal?> DecimalOption { get; private set; }
/// <summary>
/// Gets or Sets Decimal
/// </summary>
public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option<decimal?>(value); } }
/// <summary>
/// Used to track the state of MixedSubId
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedSubId> MixedSubIdOption { get; private set; }
/// <summary>
/// Gets or Sets MixedSubId
/// </summary>
public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = new Option<MixedSubId>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedAnyOfContent" />
/// </summary>
public class MixedAnyOfContentJsonConverter : JsonConverter<MixedAnyOfContent>
{
/// <summary>
/// Deserializes json to <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderInt = utf8JsonReader;
ClientUtils.TryDeserialize<int?>(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt);
Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader;
ClientUtils.TryDeserialize<decimal?>(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal);
Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader;
ClientUtils.TryDeserialize<MixedSubId>(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<string> varStringParsedValue = varString == null
? default
: new Option<string>(varString);
Option<bool?> varBoolParsedValue = varBool == null
? default
: new Option<bool?>(varBool);
Option<int?> varIntParsedValue = varInt == null
? default
: new Option<int?>(varInt);
Option<decimal?> varDecimalParsedValue = varDecimal == null
? default
: new Option<decimal?>(varDecimal);
Option<MixedSubId> mixedSubIdParsedValue = mixedSubId == null
? default
: new Option<MixedSubId>(mixedSubId);
return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue);
}
/// <summary>
/// Serializes a <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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();
}
/// <summary>
/// Serializes the properties of <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions)
{
}
}
}

View File

@ -0,0 +1,178 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedOneOf
/// </summary>
public partial class MixedOneOf : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOf" /> class.
/// </summary>
/// <param name="content">content</param>
[JsonConstructor]
public MixedOneOf(Option<MixedOneOfContent> content = default)
{
ContentOption = content;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Content
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedOneOfContent> ContentOption { get; private set; }
/// <summary>
/// Gets or Sets Content
/// </summary>
[JsonPropertyName("content")]
public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = new Option<MixedOneOfContent>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedOneOf" />
/// </summary>
public class MixedOneOfJsonConverter : JsonConverter<MixedOneOf>
{
/// <summary>
/// Deserializes json to <see cref="MixedOneOf" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<MixedOneOfContent> 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<MixedOneOfContent>(JsonSerializer.Deserialize<MixedOneOfContent>(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);
}
/// <summary>
/// Serializes a <see cref="MixedOneOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedOneOf, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedOneOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}
}

View File

@ -0,0 +1,261 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// Mixed oneOf types for testing
/// </summary>
public partial class MixedOneOfContent : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="string"></param>
public MixedOneOfContent(string @string)
{
String = @string;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="bool"></param>
public MixedOneOfContent(bool @bool)
{
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="int"></param>
public MixedOneOfContent(int @int)
{
Int = @int;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="decimal"></param>
public MixedOneOfContent(decimal @decimal)
{
Decimal = @decimal;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="mixedSubId"></param>
public MixedOneOfContent(MixedSubId mixedSubId)
{
MixedSubId = mixedSubId;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets String
/// </summary>
public string String { get; set; }
/// <summary>
/// Gets or Sets Bool
/// </summary>
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets Int
/// </summary>
public int? Int { get; set; }
/// <summary>
/// Gets or Sets Decimal
/// </summary>
public decimal? Decimal { get; set; }
/// <summary>
/// Gets or Sets MixedSubId
/// </summary>
public MixedSubId MixedSubId { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedOneOfContent" />
/// </summary>
public class MixedOneOfContentJsonConverter : JsonConverter<MixedOneOfContent>
{
/// <summary>
/// Deserializes json to <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderInt = utf8JsonReader;
ClientUtils.TryDeserialize<int?>(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt);
Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader;
ClientUtils.TryDeserialize<decimal?>(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal);
Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader;
ClientUtils.TryDeserialize<MixedSubId>(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();
}
/// <summary>
/// Serializes a <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions)
{
}
}
}

View File

@ -0,0 +1,174 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedSubId
/// </summary>
public partial class MixedSubId : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedSubId" /> class.
/// </summary>
/// <param name="id">id</param>
[JsonConstructor]
public MixedSubId(Option<string> id = default)
{
IdOption = id;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Id
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<string> IdOption { get; private set; }
/// <summary>
/// Gets or Sets Id
/// </summary>
[JsonPropertyName("id")]
public string Id { get { return this.IdOption; } set { this.IdOption = new Option<string>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedSubId" />
/// </summary>
public class MixedSubIdJsonConverter : JsonConverter<MixedSubId>
{
/// <summary>
/// Deserializes json to <see cref="MixedSubId" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string> 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<string>(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);
}
/// <summary>
/// Serializes a <see cref="MixedSubId" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedSubId"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedSubId, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedSubId" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedSubId"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -232,17 +232,20 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -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

View File

@ -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:

View File

@ -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)
<a id="getmixedanyof"></a>
# **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<MixedAnyOf> 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)
<a id="getmixedoneof"></a>
# **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<MixedOneOf> 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)
<a id="testadditionalpropertiesreference"></a>
# **TestAdditionalPropertiesReference**
> void TestAdditionalPropertiesReference (Dictionary<string, Object> requestBody)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -121,6 +121,28 @@ namespace Org.OpenAPITools.Test.Api
Assert.IsType<List<OuterEnum>>(model);
}
/// <summary>
/// Test GetMixedAnyOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedAnyOfAsyncTest()
{
var response = await _instance.GetMixedAnyOfAsync();
var model = response.Ok();
Assert.IsType<MixedAnyOf>(model);
}
/// <summary>
/// Test GetMixedOneOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedOneOfAsyncTest()
{
var response = await _instance.GetMixedOneOfAsync();
var model = response.Ok();
Assert.IsType<MixedOneOf>(model);
}
/// <summary>
/// Test TestAdditionalPropertiesReference
/// </summary>

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOfContent
/// </summary>
[Fact]
public void MixedAnyOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOfContent
//Assert.IsType<MixedAnyOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOf
/// </summary>
[Fact]
public void MixedAnyOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOf
//Assert.IsType<MixedAnyOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOfContent
/// </summary>
[Fact]
public void MixedOneOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOfContent
//Assert.IsType<MixedOneOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOf
/// </summary>
[Fact]
public void MixedOneOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOf
//Assert.IsType<MixedOneOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedSubId
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedSubId
/// </summary>
[Fact]
public void MixedSubIdInstanceTest()
{
// TODO uncomment below to test "IsType" MixedSubId
//Assert.IsType<MixedSubId>(instance);
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Fact]
public void IdTest()
{
// TODO unit test for the property 'Id'
}
}
}

View File

@ -169,6 +169,48 @@ namespace Org.OpenAPITools.Api
/// <returns><see cref="Task"/>&lt;<see cref="IGetArrayOfEnumsApiResponse"/>&gt;</returns>
Task<IGetArrayOfEnumsApiResponse> GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
Task<IGetMixedOneOfApiResponse> GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
Task<IGetMixedOneOfApiResponse> GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// test referenced additionalProperties
/// </summary>
@ -588,6 +630,30 @@ namespace Org.OpenAPITools.Api
bool IsOk { get; }
}
/// <summary>
/// The <see cref="IGetMixedAnyOfApiResponse"/>
/// </summary>
public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.MixedAnyOf>
{
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
bool IsOk { get; }
}
/// <summary>
/// The <see cref="IGetMixedOneOfApiResponse"/>
/// </summary>
public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.MixedOneOf>
{
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
bool IsOk { get; }
}
/// <summary>
/// The <see cref="ITestAdditionalPropertiesReferenceApiResponse"/>
/// </summary>
@ -869,6 +935,46 @@ namespace Org.OpenAPITools.Api
OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
public event EventHandler<ApiResponseEventArgs> OnGetMixedAnyOf;
/// <summary>
/// The event raised after an error querying the server
/// </summary>
public event EventHandler<ExceptionEventArgs> OnErrorGetMixedAnyOf;
internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse)
{
OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse));
}
internal void ExecuteOnErrorGetMixedAnyOf(Exception exception)
{
OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
public event EventHandler<ApiResponseEventArgs> OnGetMixedOneOf;
/// <summary>
/// The event raised after an error querying the server
/// </summary>
public event EventHandler<ExceptionEventArgs> OnErrorGetMixedOneOf;
internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse)
{
OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse));
}
internal void ExecuteOnErrorGetMixedOneOf(Exception exception)
{
OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
@ -2477,6 +2583,392 @@ namespace Org.OpenAPITools.Api
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="apiResponseLocalVar"></param>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="apiResponseLocalVar"></param>
partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar);
/// <summary>
/// Logs exceptions that occur while retrieving the server response
/// </summary>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
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.");
}
/// <summary>
/// A partial method that gives developers a way to provide customized exception handling
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedAnyOfApiResponse> 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<GetMixedAnyOfApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetMixedAnyOfApiResponse>();
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;
}
}
/// <summary>
/// The <see cref="GetMixedAnyOfApiResponse"/>
/// </summary>
public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse
{
/// <summary>
/// The logger
/// </summary>
public ILogger<GetMixedAnyOfApiResponse> Logger { get; }
/// <summary>
/// The <see cref="GetMixedAnyOfApiResponse"/>
/// </summary>
/// <param name="logger"></param>
/// <param name="httpRequestMessage"></param>
/// <param name="httpResponseMessage"></param>
/// <param name="rawContent"></param>
/// <param name="path"></param>
/// <param name="requestedAt"></param>
/// <param name="jsonSerializerOptions"></param>
public GetMixedAnyOfApiResponse(ILogger<GetMixedAnyOfApiResponse> 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);
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
public bool IsOk => 200 == (int)StatusCode;
/// <summary>
/// Deserializes the response if the response is 200 Ok
/// </summary>
/// <returns></returns>
public Org.OpenAPITools.Model.MixedAnyOf Ok()
{
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.MixedAnyOf>(RawContent, _jsonSerializerOptions)
: default;
}
/// <summary>
/// Returns true if the response is 200 Ok and the deserialized response is not null
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="apiResponseLocalVar"></param>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="apiResponseLocalVar"></param>
partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar);
/// <summary>
/// Logs exceptions that occur while retrieving the server response
/// </summary>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
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.");
}
/// <summary>
/// A partial method that gives developers a way to provide customized exception handling
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedOneOfApiResponse> GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedOneOfApiResponse> 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<GetMixedOneOfApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetMixedOneOfApiResponse>();
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;
}
}
/// <summary>
/// The <see cref="GetMixedOneOfApiResponse"/>
/// </summary>
public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse
{
/// <summary>
/// The logger
/// </summary>
public ILogger<GetMixedOneOfApiResponse> Logger { get; }
/// <summary>
/// The <see cref="GetMixedOneOfApiResponse"/>
/// </summary>
/// <param name="logger"></param>
/// <param name="httpRequestMessage"></param>
/// <param name="httpResponseMessage"></param>
/// <param name="rawContent"></param>
/// <param name="path"></param>
/// <param name="requestedAt"></param>
/// <param name="jsonSerializerOptions"></param>
public GetMixedOneOfApiResponse(ILogger<GetMixedOneOfApiResponse> 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);
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
public bool IsOk => 200 == (int)StatusCode;
/// <summary>
/// Deserializes the response if the response is 200 Ok
/// </summary>
/// <returns></returns>
public Org.OpenAPITools.Model.MixedOneOf Ok()
{
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.MixedOneOf>(RawContent, _jsonSerializerOptions)
: default;
}
/// <summary>
/// Returns true if the response is 200 Ok and the deserialized response is not null
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
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<string, Object> requestBody);
/// <summary>

View File

@ -85,7 +85,12 @@ namespace Org.OpenAPITools.Client
_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());

View File

@ -232,17 +232,20 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -0,0 +1,178 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedAnyOf
/// </summary>
public partial class MixedAnyOf : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedAnyOf" /> class.
/// </summary>
/// <param name="content">content</param>
[JsonConstructor]
public MixedAnyOf(Option<MixedAnyOfContent> content = default)
{
ContentOption = content;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Content
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedAnyOfContent> ContentOption { get; private set; }
/// <summary>
/// Gets or Sets Content
/// </summary>
[JsonPropertyName("content")]
public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = new Option<MixedAnyOfContent>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedAnyOf" />
/// </summary>
public class MixedAnyOfJsonConverter : JsonConverter<MixedAnyOf>
{
/// <summary>
/// Deserializes json to <see cref="MixedAnyOf" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<MixedAnyOfContent> 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<MixedAnyOfContent>(JsonSerializer.Deserialize<MixedAnyOfContent>(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);
}
/// <summary>
/// Serializes a <see cref="MixedAnyOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedAnyOf, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedAnyOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}
}

View File

@ -0,0 +1,283 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// Mixed anyOf types for testing
/// </summary>
public partial class MixedAnyOfContent : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedAnyOfContent" /> class.
/// </summary>
/// <param name="string"></param>
/// <param name="bool"></param>
/// <param name="int"></param>
/// <param name="decimal"></param>
/// <param name="mixedSubId"></param>
public MixedAnyOfContent(Option<string> @string, Option<bool?> @bool, Option<int?> @int, Option<decimal?> @decimal, Option<MixedSubId> mixedSubId)
{
StringOption = @string;
BoolOption = @bool;
IntOption = @int;
DecimalOption = @decimal;
MixedSubIdOption = mixedSubId;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of String
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<string> StringOption { get; private set; }
/// <summary>
/// Gets or Sets String
/// </summary>
public string String { get { return this.StringOption; } set { this.StringOption = new Option<string>(value); } }
/// <summary>
/// Used to track the state of Bool
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<bool?> BoolOption { get; private set; }
/// <summary>
/// Gets or Sets Bool
/// </summary>
public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option<bool?>(value); } }
/// <summary>
/// Used to track the state of Int
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<int?> IntOption { get; private set; }
/// <summary>
/// Gets or Sets Int
/// </summary>
public int? Int { get { return this.IntOption; } set { this.IntOption = new Option<int?>(value); } }
/// <summary>
/// Used to track the state of Decimal
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<decimal?> DecimalOption { get; private set; }
/// <summary>
/// Gets or Sets Decimal
/// </summary>
public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option<decimal?>(value); } }
/// <summary>
/// Used to track the state of MixedSubId
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedSubId> MixedSubIdOption { get; private set; }
/// <summary>
/// Gets or Sets MixedSubId
/// </summary>
public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = new Option<MixedSubId>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedAnyOfContent" />
/// </summary>
public class MixedAnyOfContentJsonConverter : JsonConverter<MixedAnyOfContent>
{
/// <summary>
/// Deserializes json to <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderInt = utf8JsonReader;
ClientUtils.TryDeserialize<int?>(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt);
Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader;
ClientUtils.TryDeserialize<decimal?>(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal);
Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader;
ClientUtils.TryDeserialize<MixedSubId>(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<string> varStringParsedValue = varString == null
? default
: new Option<string>(varString);
Option<bool?> varBoolParsedValue = varBool == null
? default
: new Option<bool?>(varBool);
Option<int?> varIntParsedValue = varInt == null
? default
: new Option<int?>(varInt);
Option<decimal?> varDecimalParsedValue = varDecimal == null
? default
: new Option<decimal?>(varDecimal);
Option<MixedSubId> mixedSubIdParsedValue = mixedSubId == null
? default
: new Option<MixedSubId>(mixedSubId);
return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue);
}
/// <summary>
/// Serializes a <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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();
}
/// <summary>
/// Serializes the properties of <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions)
{
}
}
}

View File

@ -0,0 +1,178 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedOneOf
/// </summary>
public partial class MixedOneOf : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOf" /> class.
/// </summary>
/// <param name="content">content</param>
[JsonConstructor]
public MixedOneOf(Option<MixedOneOfContent> content = default)
{
ContentOption = content;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Content
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedOneOfContent> ContentOption { get; private set; }
/// <summary>
/// Gets or Sets Content
/// </summary>
[JsonPropertyName("content")]
public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = new Option<MixedOneOfContent>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedOneOf" />
/// </summary>
public class MixedOneOfJsonConverter : JsonConverter<MixedOneOf>
{
/// <summary>
/// Deserializes json to <see cref="MixedOneOf" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<MixedOneOfContent> 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<MixedOneOfContent>(JsonSerializer.Deserialize<MixedOneOfContent>(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);
}
/// <summary>
/// Serializes a <see cref="MixedOneOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedOneOf, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedOneOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}
}

View File

@ -0,0 +1,261 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// Mixed oneOf types for testing
/// </summary>
public partial class MixedOneOfContent : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="string"></param>
public MixedOneOfContent(string @string)
{
String = @string;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="bool"></param>
public MixedOneOfContent(bool @bool)
{
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="int"></param>
public MixedOneOfContent(int @int)
{
Int = @int;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="decimal"></param>
public MixedOneOfContent(decimal @decimal)
{
Decimal = @decimal;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="mixedSubId"></param>
public MixedOneOfContent(MixedSubId mixedSubId)
{
MixedSubId = mixedSubId;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets String
/// </summary>
public string String { get; set; }
/// <summary>
/// Gets or Sets Bool
/// </summary>
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets Int
/// </summary>
public int? Int { get; set; }
/// <summary>
/// Gets or Sets Decimal
/// </summary>
public decimal? Decimal { get; set; }
/// <summary>
/// Gets or Sets MixedSubId
/// </summary>
public MixedSubId MixedSubId { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedOneOfContent" />
/// </summary>
public class MixedOneOfContentJsonConverter : JsonConverter<MixedOneOfContent>
{
/// <summary>
/// Deserializes json to <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderInt = utf8JsonReader;
ClientUtils.TryDeserialize<int?>(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt);
Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader;
ClientUtils.TryDeserialize<decimal?>(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal);
Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader;
ClientUtils.TryDeserialize<MixedSubId>(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();
}
/// <summary>
/// Serializes a <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions)
{
}
}
}

View File

@ -0,0 +1,174 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedSubId
/// </summary>
public partial class MixedSubId : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedSubId" /> class.
/// </summary>
/// <param name="id">id</param>
[JsonConstructor]
public MixedSubId(Option<string> id = default)
{
IdOption = id;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Id
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<string> IdOption { get; private set; }
/// <summary>
/// Gets or Sets Id
/// </summary>
[JsonPropertyName("id")]
public string Id { get { return this.IdOption; } set { this.IdOption = new Option<string>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedSubId" />
/// </summary>
public class MixedSubIdJsonConverter : JsonConverter<MixedSubId>
{
/// <summary>
/// Deserializes json to <see cref="MixedSubId" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string> 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<string>(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);
}
/// <summary>
/// Serializes a <see cref="MixedSubId" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedSubId"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedSubId, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedSubId" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedSubId"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -232,17 +232,20 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -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

View File

@ -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:

View File

@ -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)
<a id="getmixedanyof"></a>
# **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<MixedAnyOf> 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)
<a id="getmixedoneof"></a>
# **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<MixedOneOf> 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)
<a id="testadditionalpropertiesreference"></a>
# **TestAdditionalPropertiesReference**
> void TestAdditionalPropertiesReference (Dictionary<string, Object> requestBody)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -121,6 +121,28 @@ namespace Org.OpenAPITools.Test.Api
Assert.IsType<List<OuterEnum>>(model);
}
/// <summary>
/// Test GetMixedAnyOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedAnyOfAsyncTest()
{
var response = await _instance.GetMixedAnyOfAsync();
var model = response.Ok();
Assert.IsType<MixedAnyOf>(model);
}
/// <summary>
/// Test GetMixedOneOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedOneOfAsyncTest()
{
var response = await _instance.GetMixedOneOfAsync();
var model = response.Ok();
Assert.IsType<MixedOneOf>(model);
}
/// <summary>
/// Test TestAdditionalPropertiesReference
/// </summary>

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOfContent
/// </summary>
[Fact]
public void MixedAnyOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOfContent
//Assert.IsType<MixedAnyOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOf
/// </summary>
[Fact]
public void MixedAnyOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOf
//Assert.IsType<MixedAnyOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOfContent
/// </summary>
[Fact]
public void MixedOneOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOfContent
//Assert.IsType<MixedOneOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOf
/// </summary>
[Fact]
public void MixedOneOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOf
//Assert.IsType<MixedOneOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedSubId
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedSubId
/// </summary>
[Fact]
public void MixedSubIdInstanceTest()
{
// TODO uncomment below to test "IsType" MixedSubId
//Assert.IsType<MixedSubId>(instance);
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Fact]
public void IdTest()
{
// TODO unit test for the property 'Id'
}
}
}

View File

@ -169,6 +169,48 @@ namespace Org.OpenAPITools.Api
/// <returns><see cref="Task"/>&lt;<see cref="IGetArrayOfEnumsApiResponse"/>&gt;</returns>
Task<IGetArrayOfEnumsApiResponse> GetArrayOfEnumsOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
Task<IGetMixedOneOfApiResponse> GetMixedOneOfAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
Task<IGetMixedOneOfApiResponse> GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// test referenced additionalProperties
/// </summary>
@ -588,6 +630,30 @@ namespace Org.OpenAPITools.Api
bool IsOk { get; }
}
/// <summary>
/// The <see cref="IGetMixedAnyOfApiResponse"/>
/// </summary>
public interface IGetMixedAnyOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.MixedAnyOf>
{
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
bool IsOk { get; }
}
/// <summary>
/// The <see cref="IGetMixedOneOfApiResponse"/>
/// </summary>
public interface IGetMixedOneOfApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.MixedOneOf>
{
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
bool IsOk { get; }
}
/// <summary>
/// The <see cref="ITestAdditionalPropertiesReferenceApiResponse"/>
/// </summary>
@ -869,6 +935,46 @@ namespace Org.OpenAPITools.Api
OnErrorGetArrayOfEnums?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
public event EventHandler<ApiResponseEventArgs> OnGetMixedAnyOf;
/// <summary>
/// The event raised after an error querying the server
/// </summary>
public event EventHandler<ExceptionEventArgs> OnErrorGetMixedAnyOf;
internal void ExecuteOnGetMixedAnyOf(FakeApi.GetMixedAnyOfApiResponse apiResponse)
{
OnGetMixedAnyOf?.Invoke(this, new ApiResponseEventArgs(apiResponse));
}
internal void ExecuteOnErrorGetMixedAnyOf(Exception exception)
{
OnErrorGetMixedAnyOf?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
public event EventHandler<ApiResponseEventArgs> OnGetMixedOneOf;
/// <summary>
/// The event raised after an error querying the server
/// </summary>
public event EventHandler<ExceptionEventArgs> OnErrorGetMixedOneOf;
internal void ExecuteOnGetMixedOneOf(FakeApi.GetMixedOneOfApiResponse apiResponse)
{
OnGetMixedOneOf?.Invoke(this, new ApiResponseEventArgs(apiResponse));
}
internal void ExecuteOnErrorGetMixedOneOf(Exception exception)
{
OnErrorGetMixedOneOf?.Invoke(this, new ExceptionEventArgs(exception));
}
/// <summary>
/// The event raised after the server response
/// </summary>
@ -2477,6 +2583,392 @@ namespace Org.OpenAPITools.Api
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="apiResponseLocalVar"></param>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="apiResponseLocalVar"></param>
partial void AfterGetMixedAnyOf(ref bool suppressDefaultLog, IGetMixedAnyOfApiResponse apiResponseLocalVar);
/// <summary>
/// Logs exceptions that occur while retrieving the server response
/// </summary>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
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.");
}
/// <summary>
/// A partial method that gives developers a way to provide customized exception handling
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
partial void OnErrorGetMixedAnyOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path);
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedAnyOfApiResponse> GetMixedAnyOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await GetMixedAnyOfAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Test mixed type anyOf deserialization
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedAnyOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedAnyOfApiResponse> 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<GetMixedAnyOfApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetMixedAnyOfApiResponse>();
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;
}
}
/// <summary>
/// The <see cref="GetMixedAnyOfApiResponse"/>
/// </summary>
public partial class GetMixedAnyOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedAnyOfApiResponse
{
/// <summary>
/// The logger
/// </summary>
public ILogger<GetMixedAnyOfApiResponse> Logger { get; }
/// <summary>
/// The <see cref="GetMixedAnyOfApiResponse"/>
/// </summary>
/// <param name="logger"></param>
/// <param name="httpRequestMessage"></param>
/// <param name="httpResponseMessage"></param>
/// <param name="rawContent"></param>
/// <param name="path"></param>
/// <param name="requestedAt"></param>
/// <param name="jsonSerializerOptions"></param>
public GetMixedAnyOfApiResponse(ILogger<GetMixedAnyOfApiResponse> 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);
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
public bool IsOk => 200 == (int)StatusCode;
/// <summary>
/// Deserializes the response if the response is 200 Ok
/// </summary>
/// <returns></returns>
public Org.OpenAPITools.Model.MixedAnyOf Ok()
{
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.MixedAnyOf>(RawContent, _jsonSerializerOptions)
: default;
}
/// <summary>
/// Returns true if the response is 200 Ok and the deserialized response is not null
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="apiResponseLocalVar"></param>
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);
}
/// <summary>
/// Processes the server response
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="apiResponseLocalVar"></param>
partial void AfterGetMixedOneOf(ref bool suppressDefaultLog, IGetMixedOneOfApiResponse apiResponseLocalVar);
/// <summary>
/// Logs exceptions that occur while retrieving the server response
/// </summary>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
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.");
}
/// <summary>
/// A partial method that gives developers a way to provide customized exception handling
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
partial void OnErrorGetMixedOneOf(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path);
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedOneOfApiResponse> GetMixedOneOfOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await GetMixedOneOfAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}
/// <summary>
/// Test mixed type oneOf deserialization
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetMixedOneOfApiResponse"/>&gt;</returns>
public async Task<IGetMixedOneOfApiResponse> 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<GetMixedOneOfApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetMixedOneOfApiResponse>();
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;
}
}
/// <summary>
/// The <see cref="GetMixedOneOfApiResponse"/>
/// </summary>
public partial class GetMixedOneOfApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetMixedOneOfApiResponse
{
/// <summary>
/// The logger
/// </summary>
public ILogger<GetMixedOneOfApiResponse> Logger { get; }
/// <summary>
/// The <see cref="GetMixedOneOfApiResponse"/>
/// </summary>
/// <param name="logger"></param>
/// <param name="httpRequestMessage"></param>
/// <param name="httpResponseMessage"></param>
/// <param name="rawContent"></param>
/// <param name="path"></param>
/// <param name="requestedAt"></param>
/// <param name="jsonSerializerOptions"></param>
public GetMixedOneOfApiResponse(ILogger<GetMixedOneOfApiResponse> 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);
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
public bool IsOk => 200 == (int)StatusCode;
/// <summary>
/// Deserializes the response if the response is 200 Ok
/// </summary>
/// <returns></returns>
public Org.OpenAPITools.Model.MixedOneOf Ok()
{
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.MixedOneOf>(RawContent, _jsonSerializerOptions)
: default;
}
/// <summary>
/// Returns true if the response is 200 Ok and the deserialized response is not null
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
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<string, Object> requestBody);
/// <summary>

View File

@ -101,7 +101,12 @@ namespace Org.OpenAPITools.Client
_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());

View File

@ -232,17 +232,20 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -0,0 +1,178 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedAnyOf
/// </summary>
public partial class MixedAnyOf : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedAnyOf" /> class.
/// </summary>
/// <param name="content">content</param>
[JsonConstructor]
public MixedAnyOf(Option<MixedAnyOfContent> content = default)
{
ContentOption = content;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Content
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedAnyOfContent> ContentOption { get; private set; }
/// <summary>
/// Gets or Sets Content
/// </summary>
[JsonPropertyName("content")]
public MixedAnyOfContent Content { get { return this.ContentOption; } set { this.ContentOption = new Option<MixedAnyOfContent>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedAnyOf" />
/// </summary>
public class MixedAnyOfJsonConverter : JsonConverter<MixedAnyOf>
{
/// <summary>
/// Deserializes json to <see cref="MixedAnyOf" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<MixedAnyOfContent> 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<MixedAnyOfContent>(JsonSerializer.Deserialize<MixedAnyOfContent>(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);
}
/// <summary>
/// Serializes a <see cref="MixedAnyOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedAnyOf, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedAnyOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}
}

View File

@ -0,0 +1,283 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// Mixed anyOf types for testing
/// </summary>
public partial class MixedAnyOfContent : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedAnyOfContent" /> class.
/// </summary>
/// <param name="string"></param>
/// <param name="bool"></param>
/// <param name="int"></param>
/// <param name="decimal"></param>
/// <param name="mixedSubId"></param>
public MixedAnyOfContent(Option<string> @string, Option<bool?> @bool, Option<int?> @int, Option<decimal?> @decimal, Option<MixedSubId> mixedSubId)
{
StringOption = @string;
BoolOption = @bool;
IntOption = @int;
DecimalOption = @decimal;
MixedSubIdOption = mixedSubId;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of String
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<string> StringOption { get; private set; }
/// <summary>
/// Gets or Sets String
/// </summary>
public string String { get { return this.StringOption; } set { this.StringOption = new Option<string>(value); } }
/// <summary>
/// Used to track the state of Bool
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<bool?> BoolOption { get; private set; }
/// <summary>
/// Gets or Sets Bool
/// </summary>
public bool? Bool { get { return this.BoolOption; } set { this.BoolOption = new Option<bool?>(value); } }
/// <summary>
/// Used to track the state of Int
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<int?> IntOption { get; private set; }
/// <summary>
/// Gets or Sets Int
/// </summary>
public int? Int { get { return this.IntOption; } set { this.IntOption = new Option<int?>(value); } }
/// <summary>
/// Used to track the state of Decimal
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<decimal?> DecimalOption { get; private set; }
/// <summary>
/// Gets or Sets Decimal
/// </summary>
public decimal? Decimal { get { return this.DecimalOption; } set { this.DecimalOption = new Option<decimal?>(value); } }
/// <summary>
/// Used to track the state of MixedSubId
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedSubId> MixedSubIdOption { get; private set; }
/// <summary>
/// Gets or Sets MixedSubId
/// </summary>
public MixedSubId MixedSubId { get { return this.MixedSubIdOption; } set { this.MixedSubIdOption = new Option<MixedSubId>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedAnyOfContent" />
/// </summary>
public class MixedAnyOfContentJsonConverter : JsonConverter<MixedAnyOfContent>
{
/// <summary>
/// Deserializes json to <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderInt = utf8JsonReader;
ClientUtils.TryDeserialize<int?>(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt);
Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader;
ClientUtils.TryDeserialize<decimal?>(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal);
Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader;
ClientUtils.TryDeserialize<MixedSubId>(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<string> varStringParsedValue = varString == null
? default
: new Option<string>(varString);
Option<bool?> varBoolParsedValue = varBool == null
? default
: new Option<bool?>(varBool);
Option<int?> varIntParsedValue = varInt == null
? default
: new Option<int?>(varInt);
Option<decimal?> varDecimalParsedValue = varDecimal == null
? default
: new Option<decimal?>(varDecimal);
Option<MixedSubId> mixedSubIdParsedValue = mixedSubId == null
? default
: new Option<MixedSubId>(mixedSubId);
return new MixedAnyOfContent(varStringParsedValue, varBoolParsedValue, varIntParsedValue, varDecimalParsedValue, mixedSubIdParsedValue);
}
/// <summary>
/// Serializes a <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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();
}
/// <summary>
/// Serializes the properties of <see cref="MixedAnyOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedAnyOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOfContent mixedAnyOfContent, JsonSerializerOptions jsonSerializerOptions)
{
}
}
}

View File

@ -0,0 +1,178 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedOneOf
/// </summary>
public partial class MixedOneOf : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOf" /> class.
/// </summary>
/// <param name="content">content</param>
[JsonConstructor]
public MixedOneOf(Option<MixedOneOfContent> content = default)
{
ContentOption = content;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Content
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<MixedOneOfContent> ContentOption { get; private set; }
/// <summary>
/// Gets or Sets Content
/// </summary>
[JsonPropertyName("content")]
public MixedOneOfContent Content { get { return this.ContentOption; } set { this.ContentOption = new Option<MixedOneOfContent>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedOneOf" />
/// </summary>
public class MixedOneOfJsonConverter : JsonConverter<MixedOneOf>
{
/// <summary>
/// Deserializes json to <see cref="MixedOneOf" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<MixedOneOfContent> 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<MixedOneOfContent>(JsonSerializer.Deserialize<MixedOneOfContent>(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);
}
/// <summary>
/// Serializes a <see cref="MixedOneOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedOneOf, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedOneOf" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOf"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}
}

View File

@ -0,0 +1,261 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// Mixed oneOf types for testing
/// </summary>
public partial class MixedOneOfContent : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="string"></param>
public MixedOneOfContent(string @string)
{
String = @string;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="bool"></param>
public MixedOneOfContent(bool @bool)
{
Bool = @bool;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="int"></param>
public MixedOneOfContent(int @int)
{
Int = @int;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="decimal"></param>
public MixedOneOfContent(decimal @decimal)
{
Decimal = @decimal;
OnCreated();
}
/// <summary>
/// Initializes a new instance of the <see cref="MixedOneOfContent" /> class.
/// </summary>
/// <param name="mixedSubId"></param>
public MixedOneOfContent(MixedSubId mixedSubId)
{
MixedSubId = mixedSubId;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Gets or Sets String
/// </summary>
public string String { get; set; }
/// <summary>
/// Gets or Sets Bool
/// </summary>
public bool? Bool { get; set; }
/// <summary>
/// Gets or Sets Int
/// </summary>
public int? Int { get; set; }
/// <summary>
/// Gets or Sets Decimal
/// </summary>
public decimal? Decimal { get; set; }
/// <summary>
/// Gets or Sets MixedSubId
/// </summary>
public MixedSubId MixedSubId { get; set; }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedOneOfContent" />
/// </summary>
public class MixedOneOfContentJsonConverter : JsonConverter<MixedOneOfContent>
{
/// <summary>
/// Deserializes json to <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string>(ref utf8JsonReaderString, jsonSerializerOptions, out varString);
Utf8JsonReader utf8JsonReaderBool = utf8JsonReader;
ClientUtils.TryDeserialize<bool?>(ref utf8JsonReaderBool, jsonSerializerOptions, out varBool);
Utf8JsonReader utf8JsonReaderInt = utf8JsonReader;
ClientUtils.TryDeserialize<int?>(ref utf8JsonReaderInt, jsonSerializerOptions, out varInt);
Utf8JsonReader utf8JsonReaderDecimal = utf8JsonReader;
ClientUtils.TryDeserialize<decimal?>(ref utf8JsonReaderDecimal, jsonSerializerOptions, out varDecimal);
Utf8JsonReader utf8JsonReaderMixedSubId = utf8JsonReader;
ClientUtils.TryDeserialize<MixedSubId>(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();
}
/// <summary>
/// Serializes a <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedOneOfContent, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedOneOfContent" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedOneOfContent"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public void WriteProperties(Utf8JsonWriter writer, MixedOneOfContent mixedOneOfContent, JsonSerializerOptions jsonSerializerOptions)
{
}
}
}

View File

@ -0,0 +1,174 @@
// <auto-generated>
/*
* OpenAPI Petstore
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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
{
/// <summary>
/// MixedSubId
/// </summary>
public partial class MixedSubId : IValidatableObject
{
/// <summary>
/// Initializes a new instance of the <see cref="MixedSubId" /> class.
/// </summary>
/// <param name="id">id</param>
[JsonConstructor]
public MixedSubId(Option<string> id = default)
{
IdOption = id;
OnCreated();
}
partial void OnCreated();
/// <summary>
/// Used to track the state of Id
/// </summary>
[JsonIgnore]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public Option<string> IdOption { get; private set; }
/// <summary>
/// Gets or Sets Id
/// </summary>
[JsonPropertyName("id")]
public string Id { get { return this.IdOption; } set { this.IdOption = new Option<string>(value); } }
/// <summary>
/// Gets or Sets additional properties
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement> AdditionalProperties { get; } = new Dictionary<string, JsonElement>();
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
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();
}
/// <summary>
/// To validate all properties of the instance
/// </summary>
/// <param name="validationContext">Validation context</param>
/// <returns>Validation Result</returns>
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
{
yield break;
}
}
/// <summary>
/// A Json converter for type <see cref="MixedSubId" />
/// </summary>
public class MixedSubIdJsonConverter : JsonConverter<MixedSubId>
{
/// <summary>
/// Deserializes json to <see cref="MixedSubId" />
/// </summary>
/// <param name="utf8JsonReader"></param>
/// <param name="typeToConvert"></param>
/// <param name="jsonSerializerOptions"></param>
/// <returns></returns>
/// <exception cref="JsonException"></exception>
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<string> 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<string>(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);
}
/// <summary>
/// Serializes a <see cref="MixedSubId" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedSubId"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
writer.WriteStartObject();
WriteProperties(writer, mixedSubId, jsonSerializerOptions);
writer.WriteEndObject();
}
/// <summary>
/// Serializes the properties of <see cref="MixedSubId" />
/// </summary>
/// <param name="writer"></param>
/// <param name="mixedSubId"></param>
/// <param name="jsonSerializerOptions"></param>
/// <exception cref="NotImplementedException"></exception>
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);
}
}
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -208,12 +208,14 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -232,17 +232,20 @@ namespace Org.OpenAPITools.Model
{
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);
}

View File

@ -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

View File

@ -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:

View File

@ -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)
<a id="getmixedanyof"></a>
# **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<MixedAnyOf> 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)
<a id="getmixedoneof"></a>
# **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<MixedOneOf> 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)
<a id="testadditionalpropertiesreference"></a>
# **TestAdditionalPropertiesReference**
> void TestAdditionalPropertiesReference (Dictionary<string, Object> requestBody)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -121,6 +121,28 @@ namespace Org.OpenAPITools.Test.Api
Assert.IsType<List<OuterEnum>>(model);
}
/// <summary>
/// Test GetMixedAnyOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedAnyOfAsyncTest()
{
var response = await _instance.GetMixedAnyOfAsync();
var model = response.Ok();
Assert.IsType<MixedAnyOf>(model);
}
/// <summary>
/// Test GetMixedOneOf
/// </summary>
[Fact (Skip = "not implemented")]
public async Task GetMixedOneOfAsyncTest()
{
var response = await _instance.GetMixedOneOfAsync();
var model = response.Ok();
Assert.IsType<MixedOneOf>(model);
}
/// <summary>
/// Test TestAdditionalPropertiesReference
/// </summary>

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOfContent
/// </summary>
[Fact]
public void MixedAnyOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOfContent
//Assert.IsType<MixedAnyOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedAnyOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedAnyOf
/// </summary>
[Fact]
public void MixedAnyOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedAnyOf
//Assert.IsType<MixedAnyOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOfContent
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOfContent
/// </summary>
[Fact]
public void MixedOneOfContentInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOfContent
//Assert.IsType<MixedOneOfContent>(instance);
}
}
}

View File

@ -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
{
/// <summary>
/// Class for testing MixedOneOf
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
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.
}
/// <summary>
/// Test an instance of MixedOneOf
/// </summary>
[Fact]
public void MixedOneOfInstanceTest()
{
// TODO uncomment below to test "IsType" MixedOneOf
//Assert.IsType<MixedOneOf>(instance);
}
/// <summary>
/// Test the property 'Content'
/// </summary>
[Fact]
public void ContentTest()
{
// TODO unit test for the property 'Content'
}
}
}

Some files were not shown because too many files have changed in this diff Show More