diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
index 9d1643234f1..614eaefb230 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
@@ -1467,7 +1467,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
properties.put(NET_70_OR_LATER, true);
properties.put(NET_80_OR_LATER, true);
} else {
- throw new RuntimeException("Unhanlded case");
+ throw new RuntimeException("Unhandled case");
}
}
}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache
index 9967867ac01..09c544ac52f 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/JsonConverter.mustache
@@ -438,12 +438,18 @@
{{^isMap}}
{{^isNumeric}}
{{#isInnerEnum}}
+ {{#isNullable}}
var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{classname}}.{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}{{nrt!}}.Value{{/isNullable}}{{/required}});
if ({{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue != null)
writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
else
writer.WriteNull("{{baseName}}");
+ {{/isNullable}}
+ {{^isNullable}}
+ var {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue = {{classname}}.{{{datatypeWithEnum}}}ToJsonValue({{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}}.{{name}}{{^required}}Option.Value{{#vendorExtensions.x-is-value-type}}{{nrt!}}.Value{{/vendorExtensions.x-is-value-type}}{{/required}}{{#required}}{{#isNullable}}{{nrt!}}.Value{{/isNullable}}{{/required}});
+ writer.WriteString("{{baseName}}", {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}RawValue);
+ {{/isNullable}}
{{/isInnerEnum}}
{{^isInnerEnum}}
{{#lambda.copy}}
diff --git a/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache b/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache
index 0f484b0552e..462ded84dc1 100644
--- a/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/modelInnerEnum.mustache
@@ -74,7 +74,7 @@
{{#isString}}
///
{{/isString}}
- public static {{>EnumValueDataType}}{{#nrt}}{{#isString}}{{#isNullable}}{{nrt?}} {{^nrt}}{{#vendorExtensions.x-is-value-type}}? {{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}}{{/isString}}{{/nrt}} {{datatypeWithEnum}}ToJsonValue({{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#isString}}{{>NullConditionalProperty}}{{/isString}} value)
+ public static {{>EnumValueDataType}}{{#lambda.first}}{{#nrt}}{{#isString}}{{#isNullable}}{{nrt?}} {{^nrt}}{{#vendorExtensions.x-is-value-type}}? {{/vendorExtensions.x-is-value-type}}{{/nrt}}{{/isNullable}}{{/isString}}{{/nrt}}{{/lambda.first}} {{datatypeWithEnum}}ToJsonValue({{datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}{{#isString}}{{>NullConditionalProperty}}{{/isString}} value)
{
{{^isString}}
return ({{>EnumValueDataType}}) value;
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 0ebc00da632..cb97d470be5 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
@@ -2549,6 +2549,8 @@ components:
enum:
- ChildCat
default: ChildCat
+ required:
+ - pet_type
ArrayOfEnums:
type: array
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ChildCat.cs
index 72f70b8f77c..2db03d53e05 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -52,8 +52,8 @@ namespace Org.OpenAPITools.Model
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType
{
get{ return _PetType;}
set
@@ -62,7 +62,7 @@ namespace Org.OpenAPITools.Model
_flagPetType = true;
}
}
- private PetTypeEnum? _PetType;
+ private PetTypeEnum _PetType;
private bool _flagPetType;
///
@@ -76,10 +76,19 @@ namespace Org.OpenAPITools.Model
///
/// Initializes a new instance of the class.
///
- /// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ [JsonConstructorAttribute]
+ protected ChildCat()
{
+ this.AdditionalProperties = new Dictionary();
+ }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// name.
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
+ {
+ this._PetType = petType;
this._Name = name;
if (this.Name != null)
{
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/ChildCat.md
index 670272cc202..26fa8551f36 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/docs/models/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs
index ca3b07960c8..9d695969cc4 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ChildCat.cs
@@ -38,10 +38,10 @@ namespace UseSourceGeneration.Model
/// name
/// petType (default to PetTypeEnum.ChildCat)
[JsonConstructor]
- public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value))
+ public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType))
{
NameOption = name;
- PetTypeOption = petType;
+ PetType = petType;
OnCreated();
}
@@ -91,7 +91,7 @@ namespace UseSourceGeneration.Model
///
///
///
- public static string PetTypeEnumToJsonValue(PetTypeEnum? value)
+ public static string PetTypeEnumToJsonValue(PetTypeEnum value)
{
if (value == PetTypeEnum.ChildCat)
return "ChildCat";
@@ -99,18 +99,11 @@ namespace UseSourceGeneration.Model
throw new NotImplementedException($"Value could not be handled: '{value}'");
}
- ///
- /// Used to track the state of PetType
- ///
- [JsonIgnore]
- [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
- public new Option PetTypeOption { get; private set; }
-
///
/// Gets or Sets PetType
///
[JsonPropertyName("pet_type")]
- public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new(value); } }
+ public new PetTypeEnum PetType { get; set; }
///
/// Used to track the state of Name
@@ -195,13 +188,16 @@ namespace UseSourceGeneration.Model
}
}
+ if (!petType.IsSet)
+ throw new ArgumentException("Property is required for class ChildCat.", nameof(petType));
+
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat.");
if (petType.IsSet && petType.Value == null)
throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat.");
- return new ChildCat(name, petType);
+ return new ChildCat(name, petType.Value!.Value!);
}
///
@@ -234,11 +230,8 @@ namespace UseSourceGeneration.Model
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
- var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value!.Value);
- if (petTypeRawValue != null)
- writer.WriteString("pet_type", petTypeRawValue);
- else
- writer.WriteNull("pet_type");
+ var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType);
+ writer.WriteString("pet_type", petTypeRawValue);
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs
index 664242702ce..be92abbdce1 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumArrays.cs
@@ -334,10 +334,7 @@ namespace UseSourceGeneration.Model
JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions);
}
var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value!.Value);
- if (justSymbolRawValue != null)
- writer.WriteString("just_symbol", justSymbolRawValue);
- else
- writer.WriteNull("just_symbol");
+ writer.WriteString("just_symbol", justSymbolRawValue);
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs
index e0248de04b9..10c51ed3600 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/EnumTest.cs
@@ -844,11 +844,7 @@ namespace UseSourceGeneration.Model
public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
- if (enumStringRequiredRawValue != null)
- writer.WriteString("enum_string_required", enumStringRequiredRawValue);
- else
- writer.WriteNull("enum_string_required");
-
+ writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
@@ -859,11 +855,7 @@ namespace UseSourceGeneration.Model
writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
- if (enumStringRawValue != null)
- writer.WriteString("enum_string", enumStringRawValue);
- else
- writer.WriteNull("enum_string");
-
+ writer.WriteString("enum_string", enumStringRawValue);
if (enumTest.OuterEnumOption.IsSet)
if (enumTest.OuterEnumOption!.Value != null)
{
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs
index fd9c7e70a51..43322b5b87e 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Order.cs
@@ -393,10 +393,7 @@ namespace UseSourceGeneration.Model
writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
+ writer.WriteString("status", statusRawValue);
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs
index 2f1abbea359..10a27080916 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Pet.cs
@@ -388,11 +388,7 @@ namespace UseSourceGeneration.Model
writer.WriteNumber("id", pet.IdOption.Value!.Value);
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
-
+ writer.WriteString("status", statusRawValue);
if (pet.TagsOption.IsSet)
{
writer.WritePropertyName("tags");
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RequiredClass.cs
index 21ebb68608f..feb433e908e 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/RequiredClass.cs
@@ -674,7 +674,7 @@ namespace UseSourceGeneration.Model
///
///
///
- public static string? RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value)
+ public static string? RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value)
{
if (value == null)
return null;
@@ -1303,7 +1303,7 @@ namespace UseSourceGeneration.Model
///
///
///
- public static string? NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value)
+ public static string? NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value)
{
if (value == null)
return null;
@@ -2197,11 +2197,7 @@ namespace UseSourceGeneration.Model
writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly));
var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString);
- if (requiredNotnullableEnumStringRawValue != null)
- writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("required_notnullable_enum_string");
-
+ writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue);
writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue);
@@ -2311,11 +2307,7 @@ namespace UseSourceGeneration.Model
writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
- if (notrequiredNotnullableEnumStringRawValue != null)
- writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("notrequired_notnullable_enum_string");
-
+ writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet)
{
var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue!.Value);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs
index 5e5d680c221..754948ae198 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/Zebra.cs
@@ -285,10 +285,7 @@ namespace UseSourceGeneration.Model
writer.WriteString("className", zebra.ClassName);
var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value!.Value);
- if (typeRawValue != null)
- writer.WriteString("type", typeRawValue);
- else
- writer.WriteNull("type");
+ writer.WriteString("type", typeRawValue);
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs
index 57bf9caf969..ba9599e0717 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/ZeroBasedEnumClass.cs
@@ -236,10 +236,7 @@ namespace UseSourceGeneration.Model
public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
- if (zeroBasedEnumRawValue != null)
- writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
- else
- writer.WriteNull("ZeroBasedEnum");
+ writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md
index b8f7d81fbbe..88fe8f7a7fd 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/docs/models/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs
index 123bbee8012..4a9624ad241 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -37,10 +37,10 @@ namespace Org.OpenAPITools.Model
/// name
/// petType (default to PetTypeEnum.ChildCat)
[JsonConstructor]
- public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value))
+ public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType))
{
NameOption = name;
- PetTypeOption = petType;
+ PetType = petType;
OnCreated();
}
@@ -90,7 +90,7 @@ namespace Org.OpenAPITools.Model
///
///
///
- public static string PetTypeEnumToJsonValue(PetTypeEnum? value)
+ public static string PetTypeEnumToJsonValue(PetTypeEnum value)
{
if (value == PetTypeEnum.ChildCat)
return "ChildCat";
@@ -98,18 +98,11 @@ namespace Org.OpenAPITools.Model
throw new NotImplementedException($"Value could not be handled: '{value}'");
}
- ///
- /// Used to track the state of PetType
- ///
- [JsonIgnore]
- [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
- public new Option PetTypeOption { get; private set; }
-
///
/// Gets or Sets PetType
///
[JsonPropertyName("pet_type")]
- public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new(value); } }
+ public new PetTypeEnum PetType { get; set; }
///
/// Used to track the state of Name
@@ -194,13 +187,16 @@ namespace Org.OpenAPITools.Model
}
}
+ if (!petType.IsSet)
+ throw new ArgumentException("Property is required for class ChildCat.", nameof(petType));
+
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat.");
if (petType.IsSet && petType.Value == null)
throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat.");
- return new ChildCat(name, petType);
+ return new ChildCat(name, petType.Value!.Value!);
}
///
@@ -233,11 +229,8 @@ namespace Org.OpenAPITools.Model
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
- var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value!.Value);
- if (petTypeRawValue != null)
- writer.WriteString("pet_type", petTypeRawValue);
- else
- writer.WriteNull("pet_type");
+ var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType);
+ writer.WriteString("pet_type", petTypeRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs
index 4347dd97453..423dffd7b64 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -333,10 +333,7 @@ namespace Org.OpenAPITools.Model
JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions);
}
var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value!.Value);
- if (justSymbolRawValue != null)
- writer.WriteString("just_symbol", justSymbolRawValue);
- else
- writer.WriteNull("just_symbol");
+ writer.WriteString("just_symbol", justSymbolRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs
index 25b33663930..4cea89ad285 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -843,11 +843,7 @@ namespace Org.OpenAPITools.Model
public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
- if (enumStringRequiredRawValue != null)
- writer.WriteString("enum_string_required", enumStringRequiredRawValue);
- else
- writer.WriteNull("enum_string_required");
-
+ writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
@@ -858,11 +854,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
- if (enumStringRawValue != null)
- writer.WriteString("enum_string", enumStringRawValue);
- else
- writer.WriteNull("enum_string");
-
+ writer.WriteString("enum_string", enumStringRawValue);
if (enumTest.OuterEnumOption.IsSet)
if (enumTest.OuterEnumOption!.Value != null)
{
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs
index 7b771cdc8b5..41874cbf407 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Order.cs
@@ -392,10 +392,7 @@ namespace Org.OpenAPITools.Model
writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
+ writer.WriteString("status", statusRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs
index f1381bcc877..9bfe1b6a2fd 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Pet.cs
@@ -387,11 +387,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("id", pet.IdOption.Value!.Value);
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
-
+ writer.WriteString("status", statusRawValue);
if (pet.TagsOption.IsSet)
{
writer.WritePropertyName("tags");
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RequiredClass.cs
index 1ab35bd5ff6..2d1f51cd978 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -673,7 +673,7 @@ namespace Org.OpenAPITools.Model
///
///
///
- public static string? RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value)
+ public static string? RequiredNullableEnumStringEnumToJsonValue(RequiredNullableEnumStringEnum? value)
{
if (value == null)
return null;
@@ -1302,7 +1302,7 @@ namespace Org.OpenAPITools.Model
///
///
///
- public static string? NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value)
+ public static string? NotrequiredNullableEnumStringEnumToJsonValue(NotrequiredNullableEnumStringEnum? value)
{
if (value == null)
return null;
@@ -2196,11 +2196,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly));
var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString);
- if (requiredNotnullableEnumStringRawValue != null)
- writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("required_notnullable_enum_string");
-
+ writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue);
writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue);
@@ -2310,11 +2306,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
- if (notrequiredNotnullableEnumStringRawValue != null)
- writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("notrequired_notnullable_enum_string");
-
+ writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet)
{
var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue!.Value);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs
index f009907a9d1..847ee5037af 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Zebra.cs
@@ -284,10 +284,7 @@ namespace Org.OpenAPITools.Model
writer.WriteString("className", zebra.ClassName);
var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value!.Value);
- if (typeRawValue != null)
- writer.WriteString("type", typeRawValue);
- else
- writer.WriteNull("type");
+ writer.WriteString("type", typeRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index c7083ab9d5b..3c4832e9a36 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -235,10 +235,7 @@ namespace Org.OpenAPITools.Model
public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value!.Value);
- if (zeroBasedEnumRawValue != null)
- writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
- else
- writer.WriteNull("ZeroBasedEnum");
+ writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md
index b8f7d81fbbe..88fe8f7a7fd 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/docs/models/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs
index b10f05b2a5a..87996761c2a 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -35,10 +35,10 @@ namespace Org.OpenAPITools.Model
/// name
/// petType (default to PetTypeEnum.ChildCat)
[JsonConstructor]
- public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value))
+ public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType))
{
NameOption = name;
- PetTypeOption = petType;
+ PetType = petType;
OnCreated();
}
@@ -88,7 +88,7 @@ namespace Org.OpenAPITools.Model
///
///
///
- public static string PetTypeEnumToJsonValue(PetTypeEnum? value)
+ public static string PetTypeEnumToJsonValue(PetTypeEnum value)
{
if (value == PetTypeEnum.ChildCat)
return "ChildCat";
@@ -96,18 +96,11 @@ namespace Org.OpenAPITools.Model
throw new NotImplementedException($"Value could not be handled: '{value}'");
}
- ///
- /// Used to track the state of PetType
- ///
- [JsonIgnore]
- [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
- public new Option PetTypeOption { get; private set; }
-
///
/// Gets or Sets PetType
///
[JsonPropertyName("pet_type")]
- public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new(value); } }
+ public new PetTypeEnum PetType { get; set; }
///
/// Used to track the state of Name
@@ -192,13 +185,16 @@ namespace Org.OpenAPITools.Model
}
}
+ if (!petType.IsSet)
+ throw new ArgumentException("Property is required for class ChildCat.", nameof(petType));
+
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat.");
if (petType.IsSet && petType.Value == null)
throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat.");
- return new ChildCat(name, petType);
+ return new ChildCat(name, petType.Value.Value);
}
///
@@ -231,11 +227,8 @@ namespace Org.OpenAPITools.Model
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
- var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value.Value);
- if (petTypeRawValue != null)
- writer.WriteString("pet_type", petTypeRawValue);
- else
- writer.WriteNull("pet_type");
+ var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType);
+ writer.WriteString("pet_type", petTypeRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs
index 44ebb6856cb..b7ed50d1539 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -331,10 +331,7 @@ namespace Org.OpenAPITools.Model
JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions);
}
var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value.Value);
- if (justSymbolRawValue != null)
- writer.WriteString("just_symbol", justSymbolRawValue);
- else
- writer.WriteNull("just_symbol");
+ writer.WriteString("just_symbol", justSymbolRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs
index ce39b4cb9ad..9fadfdcbf35 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -841,11 +841,7 @@ namespace Org.OpenAPITools.Model
public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
- if (enumStringRequiredRawValue != null)
- writer.WriteString("enum_string_required", enumStringRequiredRawValue);
- else
- writer.WriteNull("enum_string_required");
-
+ writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value.Value));
@@ -856,11 +852,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value.Value));
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value.Value);
- if (enumStringRawValue != null)
- writer.WriteString("enum_string", enumStringRawValue);
- else
- writer.WriteNull("enum_string");
-
+ writer.WriteString("enum_string", enumStringRawValue);
if (enumTest.OuterEnumOption.IsSet)
if (enumTest.OuterEnumOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs
index 57515c27c5e..26c5042777a 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Order.cs
@@ -390,10 +390,7 @@ namespace Org.OpenAPITools.Model
writer.WriteString("shipDate", order.ShipDateOption.Value.Value.ToString(ShipDateFormat));
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
+ writer.WriteString("status", statusRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs
index f9e7d0466b2..5721a962ba2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Pet.cs
@@ -385,11 +385,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("id", pet.IdOption.Value.Value);
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
-
+ writer.WriteString("status", statusRawValue);
if (pet.TagsOption.IsSet)
{
writer.WritePropertyName("tags");
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RequiredClass.cs
index a7a41e724c5..2140e9c5ae5 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2194,11 +2194,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly));
var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString);
- if (requiredNotnullableEnumStringRawValue != null)
- writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("required_notnullable_enum_string");
-
+ writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue);
writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue);
@@ -2308,11 +2304,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value.Value));
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value.Value);
- if (notrequiredNotnullableEnumStringRawValue != null)
- writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("notrequired_notnullable_enum_string");
-
+ writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet)
{
var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue.Value);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs
index 01397462445..00f33922b86 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/Zebra.cs
@@ -282,10 +282,7 @@ namespace Org.OpenAPITools.Model
writer.WriteString("className", zebra.ClassName);
var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value.Value);
- if (typeRawValue != null)
- writer.WriteString("type", typeRawValue);
- else
- writer.WriteNull("type");
+ writer.WriteString("type", typeRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 3aa6583fff6..511fa98fa5f 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -233,10 +233,7 @@ namespace Org.OpenAPITools.Model
public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
- if (zeroBasedEnumRawValue != null)
- writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
- else
- writer.WriteNull("ZeroBasedEnum");
+ writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md
index b8f7d81fbbe..88fe8f7a7fd 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/docs/models/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs
index 52579d16971..557fdc97b0a 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -35,10 +35,10 @@ namespace Org.OpenAPITools.Model
/// name
/// petType (default to PetTypeEnum.ChildCat)
[JsonConstructor]
- public ChildCat(Option name = default, Option petType = default) : base(ChildCat.PetTypeEnumToJsonValue(petType.Value))
+ public ChildCat(Option name = default, PetTypeEnum petType = PetTypeEnum.ChildCat) : base(ChildCat.PetTypeEnumToJsonValue(petType))
{
NameOption = name;
- PetTypeOption = petType;
+ PetType = petType;
OnCreated();
}
@@ -88,7 +88,7 @@ namespace Org.OpenAPITools.Model
///
///
///
- public static string PetTypeEnumToJsonValue(PetTypeEnum? value)
+ public static string PetTypeEnumToJsonValue(PetTypeEnum value)
{
if (value == PetTypeEnum.ChildCat)
return "ChildCat";
@@ -96,18 +96,11 @@ namespace Org.OpenAPITools.Model
throw new NotImplementedException($"Value could not be handled: '{value}'");
}
- ///
- /// Used to track the state of PetType
- ///
- [JsonIgnore]
- [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
- public new Option PetTypeOption { get; private set; }
-
///
/// Gets or Sets PetType
///
[JsonPropertyName("pet_type")]
- public new PetTypeEnum? PetType { get { return this.PetTypeOption; } set { this.PetTypeOption = new Option(value); } }
+ public new PetTypeEnum PetType { get; set; }
///
/// Used to track the state of Name
@@ -192,13 +185,16 @@ namespace Org.OpenAPITools.Model
}
}
+ if (!petType.IsSet)
+ throw new ArgumentException("Property is required for class ChildCat.", nameof(petType));
+
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class ChildCat.");
if (petType.IsSet && petType.Value == null)
throw new ArgumentNullException(nameof(petType), "Property is not nullable for class ChildCat.");
- return new ChildCat(name, petType);
+ return new ChildCat(name, petType.Value.Value);
}
///
@@ -231,11 +227,8 @@ namespace Org.OpenAPITools.Model
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
- var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetTypeOption.Value.Value);
- if (petTypeRawValue != null)
- writer.WriteString("pet_type", petTypeRawValue);
- else
- writer.WriteNull("pet_type");
+ var petTypeRawValue = ChildCat.PetTypeEnumToJsonValue(childCat.PetType);
+ writer.WriteString("pet_type", petTypeRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs
index 4780ffd6faf..0234ed5742e 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -331,10 +331,7 @@ namespace Org.OpenAPITools.Model
JsonSerializer.Serialize(writer, enumArrays.ArrayEnum, jsonSerializerOptions);
}
var justSymbolRawValue = EnumArrays.JustSymbolEnumToJsonValue(enumArrays.JustSymbolOption.Value.Value);
- if (justSymbolRawValue != null)
- writer.WriteString("just_symbol", justSymbolRawValue);
- else
- writer.WriteNull("just_symbol");
+ writer.WriteString("just_symbol", justSymbolRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs
index 0a730df5230..a49eb0130a4 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -841,11 +841,7 @@ namespace Org.OpenAPITools.Model
public void WriteProperties(ref Utf8JsonWriter writer, EnumTest enumTest, JsonSerializerOptions jsonSerializerOptions)
{
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
- if (enumStringRequiredRawValue != null)
- writer.WriteString("enum_string_required", enumStringRequiredRawValue);
- else
- writer.WriteNull("enum_string_required");
-
+ writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value.Value));
@@ -856,11 +852,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value.Value));
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value.Value);
- if (enumStringRawValue != null)
- writer.WriteString("enum_string", enumStringRawValue);
- else
- writer.WriteNull("enum_string");
-
+ writer.WriteString("enum_string", enumStringRawValue);
if (enumTest.OuterEnumOption.IsSet)
if (enumTest.OuterEnumOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs
index 3c64766aa74..afab71d723c 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Order.cs
@@ -390,10 +390,7 @@ namespace Org.OpenAPITools.Model
writer.WriteString("shipDate", order.ShipDateOption.Value.Value.ToString(ShipDateFormat));
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
+ writer.WriteString("status", statusRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs
index 992e25a8486..59c2707e110 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Pet.cs
@@ -385,11 +385,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("id", pet.IdOption.Value.Value);
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value.Value);
- if (statusRawValue != null)
- writer.WriteString("status", statusRawValue);
- else
- writer.WriteNull("status");
-
+ writer.WriteString("status", statusRawValue);
if (pet.TagsOption.IsSet)
{
writer.WritePropertyName("tags");
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RequiredClass.cs
index f72773b3ffc..483b3a96a21 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2194,11 +2194,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("required_notnullable_enum_integer_only", RequiredClass.RequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.RequiredNotnullableEnumIntegerOnly));
var requiredNotnullableEnumStringRawValue = RequiredClass.RequiredNotnullableEnumStringEnumToJsonValue(requiredClass.RequiredNotnullableEnumString);
- if (requiredNotnullableEnumStringRawValue != null)
- writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("required_notnullable_enum_string");
-
+ writer.WriteString("required_notnullable_enum_string", requiredNotnullableEnumStringRawValue);
var requiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.RequiredNotnullableOuterEnumDefaultValue);
writer.WriteString("required_notnullable_outerEnumDefaultValue", requiredNotnullableOuterEnumDefaultValueRawValue);
@@ -2308,11 +2304,7 @@ namespace Org.OpenAPITools.Model
writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value.Value));
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value.Value);
- if (notrequiredNotnullableEnumStringRawValue != null)
- writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
- else
- writer.WriteNull("notrequired_notnullable_enum_string");
-
+ writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
if (requiredClass.NotrequiredNotnullableOuterEnumDefaultValueOption.IsSet)
{
var notrequiredNotnullableOuterEnumDefaultValueRawValue = OuterEnumDefaultValueValueConverter.ToJsonValue(requiredClass.NotrequiredNotnullableOuterEnumDefaultValue.Value);
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs
index 895e2f5553e..356384f926d 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/Zebra.cs
@@ -282,10 +282,7 @@ namespace Org.OpenAPITools.Model
writer.WriteString("className", zebra.ClassName);
var typeRawValue = Zebra.TypeEnumToJsonValue(zebra.TypeOption.Value.Value);
- if (typeRawValue != null)
- writer.WriteString("type", typeRawValue);
- else
- writer.WriteNull("type");
+ writer.WriteString("type", typeRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index c052c649769..e7baeec052c 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -233,10 +233,7 @@ namespace Org.OpenAPITools.Model
public void WriteProperties(ref Utf8JsonWriter writer, ZeroBasedEnumClass zeroBasedEnumClass, JsonSerializerOptions jsonSerializerOptions)
{
var zeroBasedEnumRawValue = ZeroBasedEnumClass.ZeroBasedEnumEnumToJsonValue(zeroBasedEnumClass.ZeroBasedEnumOption.Value.Value);
- if (zeroBasedEnumRawValue != null)
- writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
- else
- writer.WriteNull("ZeroBasedEnum");
+ writer.WriteString("ZeroBasedEnum", zeroBasedEnumRawValue);
}
}
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs
index f7d085a21ce..8b003f6b9af 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -52,17 +52,25 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType { get; set; }
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected ChildCat()
+ {
+ this.AdditionalProperties = new Dictionary();
+ }
///
/// Initializes a new instance of the class.
///
/// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
{
- this.Name = name;
this.PetType = petType;
+ this.Name = name;
this.AdditionalProperties = new Dictionary();
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-net47/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net47/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-net47/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs
index eaeb0202a26..8e76f168a65 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-net47/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -51,17 +51,25 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType { get; set; }
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected ChildCat()
+ {
+ this.AdditionalProperties = new Dictionary();
+ }
///
/// Initializes a new instance of the class.
///
/// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
{
- this.Name = name;
this.PetType = petType;
+ this.Name = name;
this.AdditionalProperties = new Dictionary();
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-net48/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net48/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-net48/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ChildCat.cs
index eaeb0202a26..8e76f168a65 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-net48/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -51,17 +51,25 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType { get; set; }
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected ChildCat()
+ {
+ this.AdditionalProperties = new Dictionary();
+ }
///
/// Initializes a new instance of the class.
///
/// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
{
- this.Name = name;
this.PetType = petType;
+ this.Name = name;
this.AdditionalProperties = new Dictionary();
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs
index eaeb0202a26..8e76f168a65 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-net5.0/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -51,17 +51,25 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType { get; set; }
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected ChildCat()
+ {
+ this.AdditionalProperties = new Dictionary();
+ }
///
/// Initializes a new instance of the class.
///
/// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
{
- this.Name = name;
this.PetType = petType;
+ this.Name = name;
this.AdditionalProperties = new Dictionary();
}
diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ChildCat.cs
index cdcba31d446..939b710f34b 100644
--- a/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -47,17 +47,22 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType { get; set; }
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected ChildCat() { }
///
/// Initializes a new instance of the class.
///
/// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
{
- this.Name = name;
this.PetType = petType;
+ this.Name = name;
}
///
diff --git a/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClient/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClient/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClient/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClient/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs
index eaeb0202a26..8e76f168a65 100644
--- a/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -51,17 +51,25 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType { get; set; }
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected ChildCat()
+ {
+ this.AdditionalProperties = new Dictionary();
+ }
///
/// Initializes a new instance of the class.
///
/// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
{
- this.Name = name;
this.PetType = petType;
+ this.Name = name;
this.AdditionalProperties = new Dictionary();
}
diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml b/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml
index 70e89968fbe..6bb06223646 100644
--- a/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml
+++ b/samples/client/petstore/csharp/OpenAPIClientCore/api/openapi.yaml
@@ -2491,6 +2491,8 @@ components:
- ChildCat
type: string
x-enum-as-string: true
+ required:
+ - pet_type
type: object
ArrayOfEnums:
items:
diff --git a/samples/client/petstore/csharp/OpenAPIClientCore/docs/ChildCat.md b/samples/client/petstore/csharp/OpenAPIClientCore/docs/ChildCat.md
index 072ad05b36d..8ce6449e5f2 100644
--- a/samples/client/petstore/csharp/OpenAPIClientCore/docs/ChildCat.md
+++ b/samples/client/petstore/csharp/OpenAPIClientCore/docs/ChildCat.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Name** | **string** | | [optional]
-**PetType** | **string** | | [optional] [default to PetTypeEnum.ChildCat]
+**PetType** | **string** | | [default to PetTypeEnum.ChildCat]
[[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/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs
index 06722c45658..fcfcb93317e 100644
--- a/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/OpenAPIClientCore/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -51,17 +51,22 @@ namespace Org.OpenAPITools.Model
///
/// Gets or Sets PetType
///
- [DataMember(Name = "pet_type", EmitDefaultValue = false)]
- public PetTypeEnum? PetType { get; set; }
+ [DataMember(Name = "pet_type", IsRequired = true, EmitDefaultValue = true)]
+ public PetTypeEnum PetType { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ [JsonConstructorAttribute]
+ protected ChildCat() { }
///
/// Initializes a new instance of the class.
///
/// name.
- /// petType (default to PetTypeEnum.ChildCat).
- public ChildCat(string name = default(string), PetTypeEnum? petType = PetTypeEnum.ChildCat) : base()
+ /// petType (required) (default to PetTypeEnum.ChildCat).
+ public ChildCat(string name = default(string), PetTypeEnum petType = PetTypeEnum.ChildCat) : base()
{
- this.Name = name;
this.PetType = petType;
+ this.Name = name;
}
///