From a3c0de935f4d2ce5b178bdb73eac3014bd086ccf Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Sat, 4 Feb 2023 02:09:33 -0500 Subject: [PATCH] fixed format of Date serialization (#14616) --- .../generichost/JsonConverter.mustache | 20 ++- ...odels-for-testing-with-http-signature.yaml | 7 + .../.openapi-generator/FILES | 2 + .../README.md | 1 + .../docs/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 70 ++++++++ .../Org.OpenAPITools/Model/DateOnlyClass.cs | 155 +++++++++++++++++ .../.openapi-generator/FILES | 2 + .../docs/models/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 69 ++++++++ .../Client/HostConfiguration.cs | 1 + .../Org.OpenAPITools/Model/DateOnlyClass.cs | 160 ++++++++++++++++++ .../src/Org.OpenAPITools/Model/FormatTest.cs | 8 +- .../Org.OpenAPITools/Model/NullableClass.cs | 11 +- .../.openapi-generator/FILES | 2 + .../docs/models/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 69 ++++++++ .../Client/HostConfiguration.cs | 1 + .../Org.OpenAPITools/Model/DateOnlyClass.cs | 158 +++++++++++++++++ .../src/Org.OpenAPITools/Model/FormatTest.cs | 8 +- .../Org.OpenAPITools/Model/NullableClass.cs | 11 +- .../.openapi-generator/FILES | 2 + .../docs/models/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 69 ++++++++ .../Client/HostConfiguration.cs | 1 + .../Org.OpenAPITools/Model/DateOnlyClass.cs | 158 +++++++++++++++++ .../src/Org.OpenAPITools/Model/FormatTest.cs | 8 +- .../Org.OpenAPITools/Model/NullableClass.cs | 11 +- .../.openapi-generator/FILES | 2 + .../OpenAPIClient-httpclient/README.md | 1 + .../docs/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 70 ++++++++ .../Org.OpenAPITools/Model/DateOnlyClass.cs | 134 +++++++++++++++ .../.openapi-generator/FILES | 2 + .../OpenAPIClient-net47/README.md | 1 + .../OpenAPIClient-net47/docs/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 70 ++++++++ .../Org.OpenAPITools/Model/DateOnlyClass.cs | 133 +++++++++++++++ .../.openapi-generator/FILES | 2 + .../OpenAPIClient-net48/README.md | 1 + .../OpenAPIClient-net48/docs/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 70 ++++++++ .../Org.OpenAPITools/Model/DateOnlyClass.cs | 133 +++++++++++++++ .../.openapi-generator/FILES | 2 + .../OpenAPIClient-net5.0/README.md | 1 + .../docs/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 70 ++++++++ .../Org.OpenAPITools/Model/DateOnlyClass.cs | 133 +++++++++++++++ .../OpenAPIClient/.openapi-generator/FILES | 2 + .../csharp-netcore/OpenAPIClient/README.md | 1 + .../OpenAPIClient/docs/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 70 ++++++++ .../Org.OpenAPITools/Model/DateOnlyClass.cs | 133 +++++++++++++++ .../.openapi-generator/FILES | 2 + .../OpenAPIClientCore/README.md | 1 + .../OpenAPIClientCore/docs/DateOnlyClass.md | 10 ++ .../Model/DateOnlyClassTests.cs | 70 ++++++++ .../Org.OpenAPITools/Model/DateOnlyClass.cs | 121 +++++++++++++ 58 files changed, 2315 insertions(+), 14 deletions(-) create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/DateOnlyClass.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DateOnlyClass.md create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs create mode 100644 samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/DateOnlyClass.cs diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/JsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/JsonConverter.mustache index 4f43027b1f90..4fc1bd336f2a 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/JsonConverter.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/generichost/JsonConverter.mustache @@ -3,6 +3,15 @@ /// {{>visibility}} class {{classname}}JsonConverter : JsonConverter<{{classname}}> { + {{#allVars}} + {{#isDate}} + /// + /// The format to use to serialize {{name}} + /// + public string {{name}}Format { get; set; } = "yyyy-MM-dd"; + + {{/isDate}} + {{/allVars}} /// /// A Json reader. /// @@ -208,8 +217,15 @@ {{/isNumeric}} {{/isEnum}} {{#isDate}} - writer.WritePropertyName("{{baseName}}"); - JsonSerializer.Serialize(writer, {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}, jsonSerializerOptions); + {{#isNullable}} + if ({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}} != null) + writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.Value.ToString(this.{{name}}Format)); + else + writer.WriteNull("{{baseName}}"); + {{/isNullable}} + {{^isNullable}} + writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}.ToString(this.{{name}}Format)); + {{/isNullable}} {{/isDate}} {{#isDateTime}} writer.WritePropertyName("{{baseName}}"); diff --git a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index e933e3069560..ff40f5077206 100644 --- a/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -2187,3 +2187,10 @@ components: format: uuid example: 72f98069-206d-4f12-9f12-3d1e525a8e84 nullable: true + DateOnlyClass: + type: object + properties: + dateOnlyProperty: + type: string + format: date + example: "2017-07-21" diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES index 7dc1db95d3c1..733114e38281 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/.openapi-generator/FILES @@ -25,6 +25,7 @@ docs/ChildCatAllOf.md docs/ClassModel.md docs/ComplexQuadrilateral.md docs/DanishPig.md +docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md @@ -141,6 +142,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md index 8b52ad6dfe06..bff23f31e564 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/README.md @@ -169,6 +169,7 @@ Class | Method | HTTP request | Description - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [Model.DanishPig](docs/DanishPig.md) + - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.DogAllOf](docs/DogAllOf.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DateOnlyClass.md new file mode 100644 index 000000000000..d0912d2ac415 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/docs/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..3bd2b54a366a --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..0b464c99403b --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,155 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + [DataContract(Name = "DateOnlyClass")] + public partial class DateOnlyClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty. + public DateOnlyClass(DateTime dateOnlyProperty = default(DateTime)) + { + this._DateOnlyProperty = dateOnlyProperty; + if (this.DateOnlyProperty != null) + { + this._flagDateOnlyProperty = true; + } + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [JsonConverter(typeof(OpenAPIDateConverter))] + [DataMember(Name = "dateOnlyProperty", EmitDefaultValue = false)] + public DateTime DateOnlyProperty + { + get{ return _DateOnlyProperty;} + set + { + _DateOnlyProperty = value; + _flagDateOnlyProperty = true; + } + } + private DateTime _DateOnlyProperty; + private bool _flagDateOnlyProperty; + + /// + /// Returns false as DateOnlyProperty should not be serialized given that it's read-only. + /// + /// false (boolean) + public bool ShouldSerializeDateOnlyProperty() + { + return _flagDateOnlyProperty; + } + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as DateOnlyClass).AreEqual; + } + + /// + /// Returns true if DateOnlyClass instances are equal + /// + /// Instance of DateOnlyClass to be compared + /// Boolean + public bool Equals(DateOnlyClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.DateOnlyProperty != null) + { + hashCode = (hashCode * 59) + this.DateOnlyProperty.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES index 8be2cdec85a2..ff892217def6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/.openapi-generator/FILES @@ -31,6 +31,7 @@ docs/models/ChildCatAllOf.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md docs/models/DanishPig.md +docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/DogAllOf.md @@ -147,6 +148,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/DateOnlyClass.md new file mode 100644 index 000000000000..5dd63b313ccf --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/docs/models/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..f98989439ede --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs index 1472ea426cdb..834af9328176 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -69,6 +69,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); + _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DogAllOfJsonConverter()); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..bc2dfcee831d --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,160 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +#nullable enable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + public partial class DateOnlyClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty + [JsonConstructor] + public DateOnlyClass(DateTime dateOnlyProperty) + { +#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' +#pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + if (dateOnlyProperty == null) + throw new ArgumentNullException("dateOnlyProperty is a required property for DateOnlyClass and cannot be null."); + +#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' +#pragma warning restore CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + DateOnlyProperty = dateOnlyProperty; + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [JsonPropertyName("dateOnlyProperty")] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type DateOnlyClass + /// + public class DateOnlyClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateOnlyProperty + /// + public string DateOnlyPropertyFormat { get; set; } = "yyyy-MM-dd"; + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override DateOnlyClass 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; + + DateTime dateOnlyProperty = 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? propertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (propertyName) + { + case "dateOnlyProperty": + dateOnlyProperty = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + break; + default: + break; + } + } + } + + return new DateOnlyClass(dateOnlyProperty); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(this.DateOnlyPropertyFormat)); + + writer.WriteEndObject(); + } + } +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs index 3d17d2b3ff63..b32ccd448a69 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs @@ -365,6 +365,11 @@ public IEnumerable Valid /// public class FormatTestJsonConverter : JsonConverter { + /// + /// The format to use to serialize Date + /// + public string DateFormat { get; set; } = "yyyy-MM-dd"; + /// /// A Json reader. /// @@ -486,8 +491,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); writer.WritePropertyName("byte"); JsonSerializer.Serialize(writer, formatTest.ByteProperty, jsonSerializerOptions); - writer.WritePropertyName("date"); - JsonSerializer.Serialize(writer, formatTest.Date, jsonSerializerOptions); + writer.WriteString("date", formatTest.Date.ToString(this.DateFormat)); writer.WritePropertyName("dateTime"); JsonSerializer.Serialize(writer, formatTest.DateTime, jsonSerializerOptions); writer.WritePropertyName("decimal"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs index 67867aac332b..c3c478cd7ce3 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/NullableClass.cs @@ -186,6 +186,11 @@ public IEnumerable Valid /// public class NullableClassJsonConverter : JsonConverter { + /// + /// The format to use to serialize DateProp + /// + public string DatePropFormat { get; set; } = "yyyy-MM-dd"; + /// /// A Json reader. /// @@ -301,8 +306,10 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value); else writer.WriteNull("boolean_prop"); - writer.WritePropertyName("date_prop"); - JsonSerializer.Serialize(writer, nullableClass.DateProp, jsonSerializerOptions); + if (nullableClass.DateProp != null) + writer.WriteString("date_prop", nullableClass.DateProp.Value.ToString(this.DatePropFormat)); + else + writer.WriteNull("date_prop"); writer.WritePropertyName("datetime_prop"); JsonSerializer.Serialize(writer, nullableClass.DatetimeProp, jsonSerializerOptions); if (nullableClass.IntegerProp != null) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES index 8be2cdec85a2..ff892217def6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/.openapi-generator/FILES @@ -31,6 +31,7 @@ docs/models/ChildCatAllOf.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md docs/models/DanishPig.md +docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/DogAllOf.md @@ -147,6 +148,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/DateOnlyClass.md new file mode 100644 index 000000000000..5dd63b313ccf --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/docs/models/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..f98989439ede --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs index 9b6dc50ff465..ad15d6f98cb0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -67,6 +67,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); + _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DogAllOfJsonConverter()); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..f1f557e110e2 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,158 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + public partial class DateOnlyClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty + [JsonConstructor] + public DateOnlyClass(DateTime dateOnlyProperty) + { +#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' +#pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + if (dateOnlyProperty == null) + throw new ArgumentNullException("dateOnlyProperty is a required property for DateOnlyClass and cannot be null."); + +#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' +#pragma warning restore CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + DateOnlyProperty = dateOnlyProperty; + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [JsonPropertyName("dateOnlyProperty")] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type DateOnlyClass + /// + public class DateOnlyClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateOnlyProperty + /// + public string DateOnlyPropertyFormat { get; set; } = "yyyy-MM-dd"; + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override DateOnlyClass 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; + + DateTime dateOnlyProperty = 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 propertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (propertyName) + { + case "dateOnlyProperty": + dateOnlyProperty = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + break; + default: + break; + } + } + } + + return new DateOnlyClass(dateOnlyProperty); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(this.DateOnlyPropertyFormat)); + + writer.WriteEndObject(); + } + } +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs index 7f32367f2ff7..562ec43b72ef 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs @@ -363,6 +363,11 @@ public IEnumerable Valid /// public class FormatTestJsonConverter : JsonConverter { + /// + /// The format to use to serialize Date + /// + public string DateFormat { get; set; } = "yyyy-MM-dd"; + /// /// A Json reader. /// @@ -484,8 +489,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); writer.WritePropertyName("byte"); JsonSerializer.Serialize(writer, formatTest.ByteProperty, jsonSerializerOptions); - writer.WritePropertyName("date"); - JsonSerializer.Serialize(writer, formatTest.Date, jsonSerializerOptions); + writer.WriteString("date", formatTest.Date.ToString(this.DateFormat)); writer.WritePropertyName("dateTime"); JsonSerializer.Serialize(writer, formatTest.DateTime, jsonSerializerOptions); writer.WritePropertyName("decimal"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs index 37de43720935..95eb77f00be1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -184,6 +184,11 @@ public IEnumerable Valid /// public class NullableClassJsonConverter : JsonConverter { + /// + /// The format to use to serialize DateProp + /// + public string DatePropFormat { get; set; } = "yyyy-MM-dd"; + /// /// A Json reader. /// @@ -299,8 +304,10 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value); else writer.WriteNull("boolean_prop"); - writer.WritePropertyName("date_prop"); - JsonSerializer.Serialize(writer, nullableClass.DateProp, jsonSerializerOptions); + if (nullableClass.DateProp != null) + writer.WriteString("date_prop", nullableClass.DateProp.Value.ToString(this.DatePropFormat)); + else + writer.WriteNull("date_prop"); writer.WritePropertyName("datetime_prop"); JsonSerializer.Serialize(writer, nullableClass.DatetimeProp, jsonSerializerOptions); if (nullableClass.IntegerProp != null) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES index 8be2cdec85a2..ff892217def6 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/.openapi-generator/FILES @@ -31,6 +31,7 @@ docs/models/ChildCatAllOf.md docs/models/ClassModel.md docs/models/ComplexQuadrilateral.md docs/models/DanishPig.md +docs/models/DateOnlyClass.md docs/models/DeprecatedObject.md docs/models/Dog.md docs/models/DogAllOf.md @@ -147,6 +148,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/DateOnlyClass.md new file mode 100644 index 000000000000..5dd63b313ccf --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/docs/models/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..f98989439ede --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,69 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs index 9b6dc50ff465..ad15d6f98cb0 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Client/HostConfiguration.cs @@ -67,6 +67,7 @@ public HostConfiguration(IServiceCollection services) _jsonOptions.Converters.Add(new ClassModelJsonConverter()); _jsonOptions.Converters.Add(new ComplexQuadrilateralJsonConverter()); _jsonOptions.Converters.Add(new DanishPigJsonConverter()); + _jsonOptions.Converters.Add(new DateOnlyClassJsonConverter()); _jsonOptions.Converters.Add(new DeprecatedObjectJsonConverter()); _jsonOptions.Converters.Add(new DogJsonConverter()); _jsonOptions.Converters.Add(new DogAllOfJsonConverter()); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..f1f557e110e2 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,158 @@ +// +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.ComponentModel.DataAnnotations; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + public partial class DateOnlyClass : IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty + [JsonConstructor] + public DateOnlyClass(DateTime dateOnlyProperty) + { +#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' +#pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + if (dateOnlyProperty == null) + throw new ArgumentNullException("dateOnlyProperty is a required property for DateOnlyClass and cannot be null."); + +#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null' +#pragma warning restore CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null' + + DateOnlyProperty = dateOnlyProperty; + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [JsonPropertyName("dateOnlyProperty")] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public Dictionary AdditionalProperties { get; } = new Dictionary(); + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + + /// + /// A Json converter for type DateOnlyClass + /// + public class DateOnlyClassJsonConverter : JsonConverter + { + /// + /// The format to use to serialize DateOnlyProperty + /// + public string DateOnlyPropertyFormat { get; set; } = "yyyy-MM-dd"; + + /// + /// A Json reader. + /// + /// + /// + /// + /// + /// + public override DateOnlyClass 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; + + DateTime dateOnlyProperty = 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 propertyName = utf8JsonReader.GetString(); + utf8JsonReader.Read(); + + switch (propertyName) + { + case "dateOnlyProperty": + dateOnlyProperty = JsonSerializer.Deserialize(ref utf8JsonReader, jsonSerializerOptions); + break; + default: + break; + } + } + } + + return new DateOnlyClass(dateOnlyProperty); + } + + /// + /// A Json writer + /// + /// + /// + /// + /// + public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions) + { + writer.WriteStartObject(); + + writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyProperty.ToString(this.DateOnlyPropertyFormat)); + + writer.WriteEndObject(); + } + } +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs index 7f32367f2ff7..562ec43b72ef 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs @@ -363,6 +363,11 @@ public IEnumerable Valid /// public class FormatTestJsonConverter : JsonConverter { + /// + /// The format to use to serialize Date + /// + public string DateFormat { get; set; } = "yyyy-MM-dd"; + /// /// A Json reader. /// @@ -484,8 +489,7 @@ public override void Write(Utf8JsonWriter writer, FormatTest formatTest, JsonSer JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions); writer.WritePropertyName("byte"); JsonSerializer.Serialize(writer, formatTest.ByteProperty, jsonSerializerOptions); - writer.WritePropertyName("date"); - JsonSerializer.Serialize(writer, formatTest.Date, jsonSerializerOptions); + writer.WriteString("date", formatTest.Date.ToString(this.DateFormat)); writer.WritePropertyName("dateTime"); JsonSerializer.Serialize(writer, formatTest.DateTime, jsonSerializerOptions); writer.WritePropertyName("decimal"); diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs index 37de43720935..95eb77f00be1 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/NullableClass.cs @@ -184,6 +184,11 @@ public IEnumerable Valid /// public class NullableClassJsonConverter : JsonConverter { + /// + /// The format to use to serialize DateProp + /// + public string DatePropFormat { get; set; } = "yyyy-MM-dd"; + /// /// A Json reader. /// @@ -299,8 +304,10 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J writer.WriteBoolean("boolean_prop", nullableClass.BooleanProp.Value); else writer.WriteNull("boolean_prop"); - writer.WritePropertyName("date_prop"); - JsonSerializer.Serialize(writer, nullableClass.DateProp, jsonSerializerOptions); + if (nullableClass.DateProp != null) + writer.WriteString("date_prop", nullableClass.DateProp.Value.ToString(this.DatePropFormat)); + else + writer.WriteNull("date_prop"); writer.WritePropertyName("datetime_prop"); JsonSerializer.Serialize(writer, nullableClass.DatetimeProp, jsonSerializerOptions); if (nullableClass.IntegerProp != null) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/.openapi-generator/FILES index c1188f7d0f52..05e402047694 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/.openapi-generator/FILES @@ -25,6 +25,7 @@ docs/ChildCatAllOf.md docs/ClassModel.md docs/ComplexQuadrilateral.md docs/DanishPig.md +docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md @@ -138,6 +139,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md index f13f14554514..31eb0250661a 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/README.md @@ -194,6 +194,7 @@ Class | Method | HTTP request | Description - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [Model.DanishPig](docs/DanishPig.md) + - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.DogAllOf](docs/DogAllOf.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DateOnlyClass.md new file mode 100644 index 000000000000..d0912d2ac415 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/docs/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..3bd2b54a366a --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..fb83bbebf29d --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,134 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using FileParameter = Org.OpenAPITools.Client.FileParameter; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + [DataContract(Name = "DateOnlyClass")] + public partial class DateOnlyClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty. + public DateOnlyClass(DateTime dateOnlyProperty = default(DateTime)) + { + this.DateOnlyProperty = dateOnlyProperty; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [DataMember(Name = "dateOnlyProperty", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as DateOnlyClass).AreEqual; + } + + /// + /// Returns true if DateOnlyClass instances are equal + /// + /// Instance of DateOnlyClass to be compared + /// Boolean + public bool Equals(DateOnlyClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.DateOnlyProperty != null) + { + hashCode = (hashCode * 59) + this.DateOnlyProperty.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/.openapi-generator/FILES index 7dc1db95d3c1..733114e38281 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/.openapi-generator/FILES @@ -25,6 +25,7 @@ docs/ChildCatAllOf.md docs/ClassModel.md docs/ComplexQuadrilateral.md docs/DanishPig.md +docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md @@ -141,6 +142,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md index da89b947ebae..244986de8245 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/README.md @@ -181,6 +181,7 @@ Class | Method | HTTP request | Description - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [Model.DanishPig](docs/DanishPig.md) + - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.DogAllOf](docs/DogAllOf.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DateOnlyClass.md new file mode 100644 index 000000000000..d0912d2ac415 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/docs/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..3bd2b54a366a --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..977c8ed78630 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + [DataContract(Name = "DateOnlyClass")] + public partial class DateOnlyClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty. + public DateOnlyClass(DateTime dateOnlyProperty = default(DateTime)) + { + this.DateOnlyProperty = dateOnlyProperty; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [DataMember(Name = "dateOnlyProperty", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as DateOnlyClass).AreEqual; + } + + /// + /// Returns true if DateOnlyClass instances are equal + /// + /// Instance of DateOnlyClass to be compared + /// Boolean + public bool Equals(DateOnlyClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.DateOnlyProperty != null) + { + hashCode = (hashCode * 59) + this.DateOnlyProperty.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/.openapi-generator/FILES index 7dc1db95d3c1..733114e38281 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/.openapi-generator/FILES @@ -25,6 +25,7 @@ docs/ChildCatAllOf.md docs/ClassModel.md docs/ComplexQuadrilateral.md docs/DanishPig.md +docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md @@ -141,6 +142,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md index da89b947ebae..244986de8245 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/README.md @@ -181,6 +181,7 @@ Class | Method | HTTP request | Description - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [Model.DanishPig](docs/DanishPig.md) + - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.DogAllOf](docs/DogAllOf.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DateOnlyClass.md new file mode 100644 index 000000000000..d0912d2ac415 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/docs/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..3bd2b54a366a --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..977c8ed78630 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net48/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + [DataContract(Name = "DateOnlyClass")] + public partial class DateOnlyClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty. + public DateOnlyClass(DateTime dateOnlyProperty = default(DateTime)) + { + this.DateOnlyProperty = dateOnlyProperty; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [DataMember(Name = "dateOnlyProperty", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as DateOnlyClass).AreEqual; + } + + /// + /// Returns true if DateOnlyClass instances are equal + /// + /// Instance of DateOnlyClass to be compared + /// Boolean + public bool Equals(DateOnlyClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.DateOnlyProperty != null) + { + hashCode = (hashCode * 59) + this.DateOnlyProperty.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/.openapi-generator/FILES index 7dc1db95d3c1..733114e38281 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/.openapi-generator/FILES @@ -25,6 +25,7 @@ docs/ChildCatAllOf.md docs/ClassModel.md docs/ComplexQuadrilateral.md docs/DanishPig.md +docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md @@ -141,6 +142,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md index da89b947ebae..244986de8245 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/README.md @@ -181,6 +181,7 @@ Class | Method | HTTP request | Description - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [Model.DanishPig](docs/DanishPig.md) + - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.DogAllOf](docs/DogAllOf.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DateOnlyClass.md new file mode 100644 index 000000000000..d0912d2ac415 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/docs/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..3bd2b54a366a --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..977c8ed78630 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + [DataContract(Name = "DateOnlyClass")] + public partial class DateOnlyClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty. + public DateOnlyClass(DateTime dateOnlyProperty = default(DateTime)) + { + this.DateOnlyProperty = dateOnlyProperty; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [DataMember(Name = "dateOnlyProperty", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as DateOnlyClass).AreEqual; + } + + /// + /// Returns true if DateOnlyClass instances are equal + /// + /// Instance of DateOnlyClass to be compared + /// Boolean + public bool Equals(DateOnlyClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.DateOnlyProperty != null) + { + hashCode = (hashCode * 59) + this.DateOnlyProperty.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClient/.openapi-generator/FILES index 37666078242c..f465ea1d3ab7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/.openapi-generator/FILES @@ -25,6 +25,7 @@ docs/ChildCatAllOf.md docs/ClassModel.md docs/ComplexQuadrilateral.md docs/DanishPig.md +docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md @@ -140,6 +141,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md index 8b52ad6dfe06..bff23f31e564 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/README.md @@ -169,6 +169,7 @@ Class | Method | HTTP request | Description - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [Model.DanishPig](docs/DanishPig.md) + - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.DogAllOf](docs/DogAllOf.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DateOnlyClass.md new file mode 100644 index 000000000000..d0912d2ac415 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/docs/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..3bd2b54a366a --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..977c8ed78630 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,133 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + [DataContract(Name = "DateOnlyClass")] + public partial class DateOnlyClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty. + public DateOnlyClass(DateTime dateOnlyProperty = default(DateTime)) + { + this.DateOnlyProperty = dateOnlyProperty; + this.AdditionalProperties = new Dictionary(); + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [DataMember(Name = "dateOnlyProperty", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Gets or Sets additional properties + /// + [JsonExtensionData] + public IDictionary AdditionalProperties { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as DateOnlyClass).AreEqual; + } + + /// + /// Returns true if DateOnlyClass instances are equal + /// + /// Instance of DateOnlyClass to be compared + /// Boolean + public bool Equals(DateOnlyClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.DateOnlyProperty != null) + { + hashCode = (hashCode * 59) + this.DateOnlyProperty.GetHashCode(); + } + if (this.AdditionalProperties != null) + { + hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/.openapi-generator/FILES b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/.openapi-generator/FILES index 37666078242c..f465ea1d3ab7 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/.openapi-generator/FILES +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/.openapi-generator/FILES @@ -25,6 +25,7 @@ docs/ChildCatAllOf.md docs/ClassModel.md docs/ComplexQuadrilateral.md docs/DanishPig.md +docs/DateOnlyClass.md docs/DefaultApi.md docs/DeprecatedObject.md docs/Dog.md @@ -140,6 +141,7 @@ src/Org.OpenAPITools/Model/ChildCatAllOf.cs src/Org.OpenAPITools/Model/ClassModel.cs src/Org.OpenAPITools/Model/ComplexQuadrilateral.cs src/Org.OpenAPITools/Model/DanishPig.cs +src/Org.OpenAPITools/Model/DateOnlyClass.cs src/Org.OpenAPITools/Model/DeprecatedObject.cs src/Org.OpenAPITools/Model/Dog.cs src/Org.OpenAPITools/Model/DogAllOf.cs diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md index da89b947ebae..244986de8245 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/README.md @@ -181,6 +181,7 @@ Class | Method | HTTP request | Description - [Model.ClassModel](docs/ClassModel.md) - [Model.ComplexQuadrilateral](docs/ComplexQuadrilateral.md) - [Model.DanishPig](docs/DanishPig.md) + - [Model.DateOnlyClass](docs/DateOnlyClass.md) - [Model.DeprecatedObject](docs/DeprecatedObject.md) - [Model.Dog](docs/Dog.md) - [Model.DogAllOf](docs/DogAllOf.md) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DateOnlyClass.md b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DateOnlyClass.md new file mode 100644 index 000000000000..d0912d2ac415 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/docs/DateOnlyClass.md @@ -0,0 +1,10 @@ +# Org.OpenAPITools.Model.DateOnlyClass + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**DateOnlyProperty** | **DateTime** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs new file mode 100644 index 000000000000..3bd2b54a366a --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools.Test/Model/DateOnlyClassTests.cs @@ -0,0 +1,70 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for 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.Api; +using Org.OpenAPITools.Model; +using Org.OpenAPITools.Client; +using System.Reflection; +using Newtonsoft.Json; + +namespace Org.OpenAPITools.Test.Model +{ + /// + /// Class for testing DateOnlyClass + /// + /// + /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). + /// Please update the test case below to test the model. + /// + public class DateOnlyClassTests : IDisposable + { + // TODO uncomment below to declare an instance variable for DateOnlyClass + //private DateOnlyClass instance; + + public DateOnlyClassTests() + { + // TODO uncomment below to create an instance of DateOnlyClass + //instance = new DateOnlyClass(); + } + + public void Dispose() + { + // Cleanup when everything is done. + } + + /// + /// Test an instance of DateOnlyClass + /// + [Fact] + public void DateOnlyClassInstanceTest() + { + // TODO uncomment below to test "IsType" DateOnlyClass + //Assert.IsType(instance); + } + + + /// + /// Test the property 'DateOnlyProperty' + /// + [Fact] + public void DateOnlyPropertyTest() + { + // TODO unit test for the property 'DateOnlyProperty' + } + + } + +} diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/DateOnlyClass.cs new file mode 100644 index 000000000000..3ffbc9c2cf48 --- /dev/null +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Model/DateOnlyClass.cs @@ -0,0 +1,121 @@ +/* + * OpenAPI Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * The version of the OpenAPI document: 1.0.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.IO; +using System.Runtime.Serialization; +using System.Text; +using System.Text.RegularExpressions; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Linq; +using System.ComponentModel.DataAnnotations; +using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter; +using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils; + +namespace Org.OpenAPITools.Model +{ + /// + /// DateOnlyClass + /// + [DataContract(Name = "DateOnlyClass")] + public partial class DateOnlyClass : IEquatable, IValidatableObject + { + /// + /// Initializes a new instance of the class. + /// + /// dateOnlyProperty. + public DateOnlyClass(DateTime dateOnlyProperty = default(DateTime)) + { + this.DateOnlyProperty = dateOnlyProperty; + } + + /// + /// Gets or Sets DateOnlyProperty + /// + [DataMember(Name = "dateOnlyProperty", EmitDefaultValue = false)] + [JsonConverter(typeof(OpenAPIDateConverter))] + public DateTime DateOnlyProperty { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class DateOnlyClass {\n"); + sb.Append(" DateOnlyProperty: ").Append(DateOnlyProperty).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input as DateOnlyClass).AreEqual; + } + + /// + /// Returns true if DateOnlyClass instances are equal + /// + /// Instance of DateOnlyClass to be compared + /// Boolean + public bool Equals(DateOnlyClass input) + { + return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.DateOnlyProperty != null) + { + hashCode = (hashCode * 59) + this.DateOnlyProperty.GetHashCode(); + } + return hashCode; + } + } + + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + public IEnumerable Validate(ValidationContext validationContext) + { + yield break; + } + } + +}