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 24810c9cee43..7c5200a51f14 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
@@ -276,9 +276,18 @@
{{/allVars}}
{{#allVars}}
{{^isNullable}}
+ {{#required}}
if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.IsSet && {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.Value == null)
throw new ArgumentNullException(nameof({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}), "Property is not nullable for class {{classname}}.");
+ {{/required}}
+ {{^required}}
+ {{^nrt}}
+ if ({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.IsSet && {{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}.Value == null)
+ throw new ArgumentNullException(nameof({{#lambda.camelcase_sanitize_param}}{{name}}{{/lambda.camelcase_sanitize_param}}), "Property is not nullable for class {{classname}}.");
+
+ {{/nrt}}
+ {{/required}}
{{/isNullable}}
{{/allVars}}
{{^vendorExtensions.x-duplicated-data-type}}
@@ -430,9 +439,18 @@
{{^isDiscriminator}}
{{^isNullable}}
{{#vendorExtensions.x-is-reference-type}}
- if ({{^required}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.IsSet && {{/required}}{{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} == null)
+ {{#required}}
+ if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} == null)
throw new ArgumentNullException(nameof({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}), "Property is required for class {{classname}}.");
+ {{/required}}
+ {{^required}}
+ {{^nrt}}
+ if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.IsSet && {{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}} == null)
+ throw new ArgumentNullException(nameof({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}), "Property is required for class {{classname}}.");
+
+ {{/nrt}}
+ {{/required}}
{{/vendorExtensions.x-is-reference-type}}
{{/isNullable}}
{{/isDiscriminator}}
diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WritePropertyHelper.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WritePropertyHelper.mustache
index 616993bcea70..9d8856e05a45 100644
--- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WritePropertyHelper.mustache
+++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/WritePropertyHelper.mustache
@@ -5,6 +5,26 @@ else
writer.WriteNull("{{baseName}}");
{{/isNullable}}
{{^isNullable}}
+{{^required}}
+{{#nrt}}
+{{#vendorExtensions.x-is-value-type}}
+if ({{#lambda.camelcase_sanitize_param}}{{classname}}{{/lambda.camelcase_sanitize_param}}.{{name}}Option.Value != null)
+ {{#lambda.paste}}{{/lambda.paste}}
+else
+ writer.WriteNull("{{baseName}}");
+{{/vendorExtensions.x-is-value-type}}
+{{^vendorExtensions.x-is-value-type}}
+{{#lambda.paste}}
+{{/lambda.paste}}
+{{/vendorExtensions.x-is-value-type}}
+{{/nrt}}
+{{^nrt}}
+{{#lambda.paste}}
+{{/lambda.paste}}
+{{/nrt}}
+{{/required}}
+{{#required}}
{{#lambda.paste}}
{{/lambda.paste}}
+{{/required}}
{{/isNullable}}
\ No newline at end of file
diff --git a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Model/HelloWorldPostRequest.cs b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Model/HelloWorldPostRequest.cs
index 91e619f2390b..005fd1370715 100644
--- a/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Model/HelloWorldPostRequest.cs
+++ b/samples/client/petstore/csharp/generichost/latest/HelloWorld/src/Org.OpenAPITools/Model/HelloWorldPostRequest.cs
@@ -128,9 +128,6 @@ public override HelloWorldPostRequest Read(ref Utf8JsonReader utf8JsonReader, Ty
}
}
- if (message.IsSet && message.Value == null)
- throw new ArgumentNullException(nameof(message), "Property is not nullable for class HelloWorldPostRequest.");
-
return new HelloWorldPostRequest(message);
}
@@ -158,9 +155,6 @@ public override void Write(Utf8JsonWriter writer, HelloWorldPostRequest helloWor
///
public void WriteProperties(Utf8JsonWriter writer, HelloWorldPostRequest helloWorldPostRequest, JsonSerializerOptions jsonSerializerOptions)
{
- if (helloWorldPostRequest.MessageOption.IsSet && helloWorldPostRequest.Message == null)
- throw new ArgumentNullException(nameof(helloWorldPostRequest.Message), "Property is required for class HelloWorldPostRequest.");
-
if (helloWorldPostRequest.MessageOption.IsSet)
writer.WriteString("message", helloWorldPostRequest.Message);
}
diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/Foo.cs
index ef709bf75ac8..517e2165dbd1 100644
--- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/Foo.cs
@@ -128,9 +128,6 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
-
return new Foo(bar);
}
@@ -158,9 +155,6 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
- if (foo.BarOption.IsSet && foo.Bar == null)
- throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");
-
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
}
diff --git a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/IconsDefaultResponse.cs b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/IconsDefaultResponse.cs
index f3bd541429d4..a3aa079b54da 100644
--- a/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/IconsDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/latest/InlineEnumAnyOf/src/Org.OpenAPITools/Model/IconsDefaultResponse.cs
@@ -128,9 +128,6 @@ public override IconsDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Typ
}
}
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class IconsDefaultResponse.");
-
return new IconsDefaultResponse(varString);
}
@@ -158,9 +155,6 @@ public override void Write(Utf8JsonWriter writer, IconsDefaultResponse iconsDefa
///
public void WriteProperties(Utf8JsonWriter writer, IconsDefaultResponse iconsDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (iconsDefaultResponse.StringOption.IsSet && iconsDefaultResponse.String == null)
- throw new ArgumentNullException(nameof(iconsDefaultResponse.String), "Property is required for class IconsDefaultResponse.");
-
if (iconsDefaultResponse.StringOption.IsSet)
{
writer.WritePropertyName("string");
diff --git a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Model/TestObject.cs b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Model/TestObject.cs
index f6e193cb8ddd..d12259a649fc 100644
--- a/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Model/TestObject.cs
+++ b/samples/client/petstore/csharp/generichost/latest/OneOfList/src/Org.OpenAPITools/Model/TestObject.cs
@@ -128,9 +128,6 @@ public override TestObject Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class TestObject.");
-
return new TestObject(name);
}
@@ -158,9 +155,6 @@ public override void Write(Utf8JsonWriter writer, TestObject testObject, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestObject testObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (testObject.NameOption.IsSet && testObject.Name == null)
- throw new ArgumentNullException(nameof(testObject.Name), "Property is required for class TestObject.");
-
if (testObject.NameOption.IsSet)
writer.WriteString("name", testObject.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Adult.cs
index e5c016d2627d..c1770389a70b 100644
--- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Adult.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Adult.cs
@@ -134,18 +134,6 @@ public override Adult Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (children.IsSet && children.Value == null)
- throw new ArgumentNullException(nameof(children), "Property is not nullable for class Adult.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Adult.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Adult.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Adult.");
-
return new Adult(children, firstName, lastName);
}
@@ -173,15 +161,6 @@ public override void Write(Utf8JsonWriter writer, Adult adult, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions)
{
- if (adult.ChildrenOption.IsSet && adult.Children == null)
- throw new ArgumentNullException(nameof(adult.Children), "Property is required for class Adult.");
-
- if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
-
- if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
-
if (adult.ChildrenOption.IsSet)
{
writer.WritePropertyName("children");
diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Child.cs
index 94cfd4f4aa62..7a142b9ac41e 100644
--- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Child.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Child.cs
@@ -154,21 +154,6 @@ public override Child Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (age.IsSet && age.Value == null)
- throw new ArgumentNullException(nameof(age), "Property is not nullable for class Child.");
-
- if (boosterSeat.IsSet && boosterSeat.Value == null)
- throw new ArgumentNullException(nameof(boosterSeat), "Property is not nullable for class Child.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Child.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Child.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Child.");
-
return new Child(age, boosterSeat, firstName, lastName);
}
@@ -196,17 +181,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
- if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
-
- if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
-
if (child.AgeOption.IsSet)
- writer.WriteNumber("age", child.AgeOption.Value!.Value);
+ if (child.AgeOption.Value != null)
+ writer.WriteNumber("age", child.AgeOption.Value!.Value);
+ else
+ writer.WriteNull("age");
if (child.BoosterSeatOption.IsSet)
- writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value);
+ if (child.BoosterSeatOption.Value != null)
+ writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value);
+ else
+ writer.WriteNull("boosterSeat");
if (child.FirstNameOption.IsSet)
writer.WriteString("firstName", child.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Person.cs
index 6da989d4e3a7..a9dedb4eb4f0 100644
--- a/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Person.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AllOf/src/Org.OpenAPITools/Model/Person.cs
@@ -186,15 +186,6 @@ public override Person Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Person.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Person.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Person.");
-
return new Person(firstName, lastName);
}
@@ -232,12 +223,6 @@ public override void Write(Utf8JsonWriter writer, Person person, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions)
{
- if (person.FirstNameOption.IsSet && person.FirstName == null)
- throw new ArgumentNullException(nameof(person.FirstName), "Property is required for class Person.");
-
- if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
-
if (person.FirstNameOption.IsSet)
writer.WriteString("firstName", person.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
index dd3528fa42a4..0826aac5f1a9 100644
--- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -136,9 +136,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
index 170ad4b54dac..1cf95d5690f7 100644
--- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
index 89b223fa5dbb..480e908afc63 100644
--- a/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -185,9 +185,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -234,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
index 8531edebf731..d51f01d8357e 100644
--- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
@@ -135,9 +135,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -165,9 +162,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
index 93897bf0b56a..1f90d47f25d4 100644
--- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
@@ -135,9 +135,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -166,7 +163,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
index 60e3c31c6a4f..b53b9cc8694d 100644
--- a/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
@@ -184,9 +184,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -233,9 +230,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
index fd37515f54a2..54a14058a611 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
@@ -136,9 +136,6 @@ public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
}
}
- if (activityOutputs.IsSet && activityOutputs.Value == null)
- throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity.");
-
return new Activity(activityOutputs);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
{
- if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null)
- throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity.");
-
if (activity.ActivityOutputsOption.IsSet)
{
writer.WritePropertyName("activity_outputs");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 80ab5ec04b8d..29e3444ae64f 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -156,12 +156,6 @@ public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8
}
}
- if (prop1.IsSet && prop1.Value == null)
- throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
- if (prop2.IsSet && prop2.Value == null)
- throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
return new ActivityOutputElementRepresentation(prop1, prop2);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent
///
public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
{
- if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation.");
-
- if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
-
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index de2cf7f84849..f56f4f0806fc 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -277,27 +277,6 @@ public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader
}
}
- if (emptyMap.IsSet && emptyMap.Value == null)
- throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapProperty.IsSet && mapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass.");
-
return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString);
}
@@ -325,27 +304,6 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi
///
public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
-
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
index 1e87e6de2950..4d36ec4ce4d4 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
@@ -172,9 +172,6 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
-
return new Animal(color);
}
@@ -212,9 +209,6 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
{
- if (animal.ColorOption.IsSet && animal.Color == null)
- throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal.");
-
writer.WriteString("className", animal.ClassName);
if (animal.ColorOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
index c7fa501c3c5d..65aa7bce8814 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -176,15 +176,6 @@ public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse.");
-
- if (message.IsSet && message.Value == null)
- throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse.");
-
return new ApiResponse(code, message, type);
}
@@ -212,14 +203,11 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
-
- if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
-
if (apiResponse.CodeOption.IsSet)
- writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ if (apiResponse.CodeOption.Value != null)
+ writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ else
+ writer.WriteNull("code");
if (apiResponse.MessageOption.IsSet)
writer.WriteString("message", apiResponse.Message);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
index 601dae95aa1a..233780d0bbf9 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
@@ -206,15 +206,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (colorCode.IsSet && colorCode.Value == null)
- throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple.");
-
- if (cultivar.IsSet && cultivar.Value == null)
- throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple.");
-
- if (origin.IsSet && origin.Value == null)
- throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple.");
-
return new Apple(colorCode, cultivar, origin);
}
@@ -242,15 +233,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.ColorCodeOption.IsSet && apple.ColorCode == null)
- throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple.");
-
- if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
-
- if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
-
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
index fdef147cb388..603ed8b1b7c8 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -148,9 +148,6 @@ public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (cultivar.IsSet && cultivar.Value == null)
throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq.");
- if (mealy.IsSet && mealy.Value == null)
- throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq.");
-
return new AppleReq(cultivar.Value!, mealy);
}
@@ -184,7 +181,10 @@ public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerial
writer.WriteString("cultivar", appleReq.Cultivar);
if (appleReq.MealyOption.IsSet)
- writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ if (appleReq.MealyOption.Value != null)
+ writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ else
+ writer.WriteNull("mealy");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index a09872cef811..e32622955178 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -136,9 +136,6 @@ public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader,
}
}
- if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly.");
-
return new ArrayOfArrayOfNumberOnly(arrayArrayNumber);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly.");
-
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index c338f29efc9d..31f190ea0bd6 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -136,9 +136,6 @@ public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (arrayNumber.IsSet && arrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly.");
-
return new ArrayOfNumberOnly(arrayNumber);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly.");
-
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
index 04609b245365..2543e616837a 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -176,15 +176,6 @@ public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
}
}
- if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest.");
-
- if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest.");
-
- if (arrayOfString.IsSet && arrayOfString.Value == null)
- throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest.");
-
return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString);
}
@@ -212,15 +203,6 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
-
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
writer.WritePropertyName("array_array_of_integer");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
index cf0ee9cdb1aa..19d507f22d49 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (lengthCm.IsSet && lengthCm.Value == null)
- throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana.");
-
return new Banana(lengthCm);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.LengthCmOption.IsSet)
- writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ if (banana.LengthCmOption.Value != null)
+ writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ else
+ writer.WriteNull("lengthCm");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
index 10375771f80b..e53a11f03ac0 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -148,9 +148,6 @@ public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
if (lengthCm.IsSet && lengthCm.Value == null)
throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq.");
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq.");
-
return new BananaReq(lengthCm.Value!.Value!, sweet);
}
@@ -181,7 +178,10 @@ public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeri
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
- writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ if (bananaReq.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
index 133845a991f0..d23f06b49376 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -237,24 +237,6 @@ public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (aTTNAME.IsSet && aTTNAME.Value == null)
- throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization.");
-
- if (capitalCamel.IsSet && capitalCamel.Value == null)
- throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization.");
-
- if (capitalSnake.IsSet && capitalSnake.Value == null)
- throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization.");
-
- if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null)
- throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization.");
-
- if (smallCamel.IsSet && smallCamel.Value == null)
- throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization.");
-
- if (smallSnake.IsSet && smallSnake.Value == null)
- throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization.");
-
return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake);
}
@@ -282,24 +264,6 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization,
///
public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
{
- if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null)
- throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
-
- if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
-
- if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
-
- if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
-
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
index 4887c6c7aff7..6933fd651942 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
@@ -135,12 +135,6 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat.");
-
- if (declawed.IsSet && declawed.Value == null)
- throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat.");
-
return new Cat(color, declawed);
}
@@ -168,16 +162,16 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
{
- if (cat.ColorOption.IsSet && cat.Color == null)
- throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat.");
-
writer.WriteString("className", cat.ClassName);
if (cat.ColorOption.IsSet)
writer.WriteString("color", cat.Color);
if (cat.DeclawedOption.IsSet)
- writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ if (cat.DeclawedOption.Value != null)
+ writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ else
+ writer.WriteNull("declawed");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
index 936d8dc8b225..f40778b17c24 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
@@ -152,9 +152,6 @@ public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (!name.IsSet)
throw new ArgumentException("Property is required for class Category.", nameof(name));
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category.");
-
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category.");
@@ -189,7 +186,10 @@ public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerial
throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
if (category.IdOption.IsSet)
- writer.WriteNumber("id", category.IdOption.Value!.Value);
+ if (category.IdOption.Value != null)
+ writer.WriteNumber("id", category.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
writer.WriteString("name", category.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
index c37ba2ec211e..cc30d23ad45c 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -189,9 +189,6 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
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.");
@@ -222,9 +219,6 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
{
- if (childCat.NameOption.IsSet && childCat.Name == null)
- throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat.");
-
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
index 5a199576ee29..77511092b81d 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -136,9 +136,6 @@ public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel.");
-
return new ClassModel(varClass);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
{
- if (classModel.ClassOption.IsSet && classModel.Class == null)
- throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel.");
-
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index d908fed19a3a..363b5623e0b3 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -142,9 +142,6 @@ public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null)
- throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass.");
-
return new DateOnlyClass(dateOnlyProperty);
}
@@ -173,7 +170,10 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
- writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ if (dateOnlyClass.DateOnlyPropertyOption.Value != null)
+ writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ else
+ writer.WriteNull("dateOnlyProperty");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index 68e0836b632f..40d33cc49b93 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -136,9 +136,6 @@ public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject.");
-
return new DeprecatedObject(name);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj
///
public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null)
- throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject.");
-
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
index 05eb0781cfe7..3336440935fa 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
@@ -135,12 +135,6 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog.");
- if (breed.IsSet && breed.Value == null)
- throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog.");
-
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog.");
-
return new Dog(breed, color);
}
@@ -168,12 +162,6 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
{
- if (dog.BreedOption.IsSet && dog.Breed == null)
- throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog.");
-
- if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
-
writer.WriteString("className", dog.ClassName);
if (dog.BreedOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
index 1668434a783f..36cda7a41304 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
@@ -196,12 +196,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (mainShape.IsSet && mainShape.Value == null)
- throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing.");
-
- if (shapes.IsSet && shapes.Value == null)
- throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing.");
-
return new Drawing(mainShape, nullableShape, shapeOrNull, shapes);
}
@@ -229,12 +223,6 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
{
- if (drawing.MainShapeOption.IsSet && drawing.MainShape == null)
- throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing.");
-
- if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
-
if (drawing.MainShapeOption.IsSet)
{
writer.WritePropertyName("mainShape");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
index 9a6f097e92c2..0dbae86d74c1 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -290,12 +290,6 @@ public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (arrayEnum.IsSet && arrayEnum.Value == null)
- throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays.");
-
- if (justSymbol.IsSet && justSymbol.Value == null)
- throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays.");
-
return new EnumArrays(arrayEnum, justSymbol);
}
@@ -323,9 +317,6 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
{
- if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null)
- throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays.");
-
if (enumArrays.ArrayEnumOption.IsSet)
{
writer.WritePropertyName("array_enum");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
index ea7a5bd26988..a6ad620905e3 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -791,27 +791,6 @@ public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (enumStringRequired.IsSet && enumStringRequired.Value == null)
throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest.");
- if (enumInteger.IsSet && enumInteger.Value == null)
- throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest.");
-
- if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest.");
-
- if (enumNumber.IsSet && enumNumber.Value == null)
- throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest.");
-
- if (enumString.IsSet && enumString.Value == null)
- throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest.");
-
- if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest.");
-
- if (outerEnumInteger.IsSet && outerEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest.");
-
- if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest.");
-
return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue);
}
@@ -842,13 +821,22 @@ public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerial
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
- writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ if (enumTest.EnumIntegerOption.Value != null)
+ writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer");
if (enumTest.EnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ if (enumTest.EnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer_only");
if (enumTest.EnumNumberOption.IsSet)
- writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ if (enumTest.EnumNumberOption.Value != null)
+ writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ else
+ writer.WriteNull("enum_number");
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
writer.WriteString("enum_string", enumStringRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
index dab2e4e27b36..bb17ff53d25e 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
@@ -137,9 +137,6 @@ public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (sourceURI.IsSet && sourceURI.Value == null)
- throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File.");
-
return new File(sourceURI);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
{
- if (file.SourceURIOption.IsSet && file.SourceURI == null)
- throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File.");
-
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 971a81e9c8c4..1b428026dab9 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -156,12 +156,6 @@ public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (file.IsSet && file.Value == null)
- throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass.");
-
- if (files.IsSet && files.Value == null)
- throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass.");
-
return new FileSchemaTestClass(file, files);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema
///
public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass.");
-
- if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
-
if (fileSchemaTestClass.FileOption.IsSet)
{
writer.WritePropertyName("file");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
index b8128f4c3e45..1649f2dcca78 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
@@ -136,9 +136,6 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
-
return new Foo(bar);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
- if (foo.BarOption.IsSet && foo.Bar == null)
- throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");
-
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index f4e54444c7ee..4b315c651541 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -136,9 +136,6 @@ public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Ty
}
}
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse.");
-
return new FooGetDefaultResponse(varString);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe
///
public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null)
- throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse.");
-
if (fooGetDefaultResponse.StringOption.IsSet)
{
writer.WritePropertyName("string");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
index 9e4b3c23fe8a..81285ddae396 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -847,75 +847,6 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (stringFormattedAsDecimalRequired.IsSet && stringFormattedAsDecimalRequired.Value == null)
throw new ArgumentNullException(nameof(stringFormattedAsDecimalRequired), "Property is not nullable for class FormatTest.");
- if (binary.IsSet && binary.Value == null)
- throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest.");
-
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest.");
-
- if (varDecimal.IsSet && varDecimal.Value == null)
- throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest.");
-
- if (varDouble.IsSet && varDouble.Value == null)
- throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName2.IsSet && duplicatePropertyName2.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName2), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName.IsSet && duplicatePropertyName.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName), "Property is not nullable for class FormatTest.");
-
- if (varFloat.IsSet && varFloat.Value == null)
- throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest.");
-
- if (int32.IsSet && int32.Value == null)
- throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest.");
-
- if (int32Range.IsSet && int32Range.Value == null)
- throw new ArgumentNullException(nameof(int32Range), "Property is not nullable for class FormatTest.");
-
- if (int64.IsSet && int64.Value == null)
- throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest.");
-
- if (int64Negative.IsSet && int64Negative.Value == null)
- throw new ArgumentNullException(nameof(int64Negative), "Property is not nullable for class FormatTest.");
-
- if (int64NegativeExclusive.IsSet && int64NegativeExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64NegativeExclusive), "Property is not nullable for class FormatTest.");
-
- if (int64Positive.IsSet && int64Positive.Value == null)
- throw new ArgumentNullException(nameof(int64Positive), "Property is not nullable for class FormatTest.");
-
- if (int64PositiveExclusive.IsSet && int64PositiveExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64PositiveExclusive), "Property is not nullable for class FormatTest.");
-
- if (integer.IsSet && integer.Value == null)
- throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest.");
-
- if (patternWithBackslash.IsSet && patternWithBackslash.Value == null)
- throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigits.IsSet && patternWithDigits.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest.");
-
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest.");
-
- if (stringFormattedAsDecimal.IsSet && stringFormattedAsDecimal.Value == null)
- throw new ArgumentNullException(nameof(stringFormattedAsDecimal), "Property is not nullable for class FormatTest.");
-
- if (unsignedInteger.IsSet && unsignedInteger.Value == null)
- throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest.");
-
- if (unsignedLong.IsSet && unsignedLong.Value == null)
- throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
-
return new FormatTest(varByte.Value!, date.Value!.Value!, number.Value!.Value!, password.Value!, stringFormattedAsDecimalRequired.Value!.Value!, binary, dateTime, varDecimal, varDouble, duplicatePropertyName2, duplicatePropertyName, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, stringFormattedAsDecimal, unsignedInteger, unsignedLong, uuid);
}
@@ -949,27 +880,6 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
if (formatTest.Password == null)
throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
-
- if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
-
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
@@ -986,7 +896,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions);
}
if (formatTest.DateTimeOption.IsSet)
- writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (formatTest.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (formatTest.DecimalOption.IsSet)
{
@@ -994,7 +907,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions);
}
if (formatTest.DoubleOption.IsSet)
- writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ if (formatTest.DoubleOption.Value != null)
+ writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ else
+ writer.WriteNull("double");
if (formatTest.DuplicatePropertyName2Option.IsSet)
writer.WriteString("duplicate_property_name", formatTest.DuplicatePropertyName2);
@@ -1003,31 +919,58 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("@duplicate_property_name", formatTest.DuplicatePropertyName);
if (formatTest.FloatOption.IsSet)
- writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ if (formatTest.FloatOption.Value != null)
+ writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ else
+ writer.WriteNull("float");
if (formatTest.Int32Option.IsSet)
- writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ if (formatTest.Int32Option.Value != null)
+ writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ else
+ writer.WriteNull("int32");
if (formatTest.Int32RangeOption.IsSet)
- writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ if (formatTest.Int32RangeOption.Value != null)
+ writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ else
+ writer.WriteNull("int32Range");
if (formatTest.Int64Option.IsSet)
- writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ if (formatTest.Int64Option.Value != null)
+ writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ else
+ writer.WriteNull("int64");
if (formatTest.Int64NegativeOption.IsSet)
- writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ if (formatTest.Int64NegativeOption.Value != null)
+ writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ else
+ writer.WriteNull("int64Negative");
if (formatTest.Int64NegativeExclusiveOption.IsSet)
- writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ if (formatTest.Int64NegativeExclusiveOption.Value != null)
+ writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64NegativeExclusive");
if (formatTest.Int64PositiveOption.IsSet)
- writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ if (formatTest.Int64PositiveOption.Value != null)
+ writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64Positive");
if (formatTest.Int64PositiveExclusiveOption.IsSet)
- writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ if (formatTest.Int64PositiveExclusiveOption.Value != null)
+ writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64PositiveExclusive");
if (formatTest.IntegerOption.IsSet)
- writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ if (formatTest.IntegerOption.Value != null)
+ writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ else
+ writer.WriteNull("integer");
if (formatTest.PatternWithBackslashOption.IsSet)
writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash);
@@ -1042,16 +985,28 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("string", formatTest.String);
if (formatTest.StringFormattedAsDecimalOption.IsSet)
- writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ if (formatTest.StringFormattedAsDecimalOption.Value != null)
+ writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ else
+ writer.WriteNull("string_formatted_as_decimal");
if (formatTest.UnsignedIntegerOption.IsSet)
- writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ if (formatTest.UnsignedIntegerOption.Value != null)
+ writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_integer");
if (formatTest.UnsignedLongOption.IsSet)
- writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ if (formatTest.UnsignedLongOption.Value != null)
+ writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_long");
if (formatTest.UuidOption.IsSet)
- writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ if (formatTest.UuidOption.Value != null)
+ writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
index eb12679ed27d..04d8d8c83466 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
@@ -174,9 +174,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -210,9 +207,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
index d751e8154524..5b8b0531a47a 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -178,9 +178,6 @@ public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -227,9 +224,6 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (gmFruit.ColorOption.IsSet && gmFruit.Color == null)
- throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit.");
-
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index 50826dd0da5d..0c383b3b1776 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -197,12 +197,6 @@ public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typ
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly.");
-
- if (foo.IsSet && foo.Value == null)
- throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly.");
-
return new HasOnlyReadOnly(bar, foo);
}
@@ -230,12 +224,6 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl
///
public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly.");
-
- if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
-
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
index ddf0d615fd3c..774eddc243a8 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
@@ -136,9 +136,6 @@ public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (var123List.IsSet && var123List.Value == null)
- throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List.");
-
return new List(var123List);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
{
- if (list.Var123ListOption.IsSet && list.Var123List == null)
- throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List.");
-
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 5993dd82adc8..3525a34b369b 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -156,12 +156,6 @@ public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (escapedLiteralString.IsSet && escapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
- if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
return new LiteralStringClass(escapedLiteralString, unescapedLiteralString);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri
///
public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass.");
-
- if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
-
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
index 06668cf78934..0b68a78dfbd5 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
@@ -262,18 +262,6 @@ public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (directMap.IsSet && directMap.Value == null)
- throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest.");
-
- if (indirectMap.IsSet && indirectMap.Value == null)
- throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest.");
-
- if (mapMapOfString.IsSet && mapMapOfString.Value == null)
- throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest.");
-
- if (mapOfEnumString.IsSet && mapOfEnumString.Value == null)
- throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest.");
-
return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString);
}
@@ -301,18 +289,6 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest.");
-
- if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
-
- if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
-
- if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
-
if (mapTest.DirectMapOption.IsSet)
{
writer.WritePropertyName("direct_map");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 266cbf7f9d2e..15d32a530899 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -136,9 +136,6 @@ public override MixedAnyOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf.");
-
return new MixedAnyOf(content);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null)
- throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf.");
-
if (mixedAnyOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
index 4d5b2c6d94cf..6be715c794d8 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -136,9 +136,6 @@ public override MixedOneOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf.");
-
return new MixedOneOf(content);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null)
- throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf.");
-
if (mixedOneOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 968a64762901..ce2e08e1e124 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -208,18 +208,6 @@ public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonRea
}
}
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (map.IsSet && map.Value == null)
- throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuidWithPattern.IsSet && uuidWithPattern.Value == null)
- throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern);
}
@@ -247,11 +235,11 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
-
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
- writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet)
{
@@ -259,10 +247,16 @@ public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalP
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions);
}
if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet)
- writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value != null)
+ writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet)
- writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value != null)
+ writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ else
+ writer.WriteNull("uuid_with_pattern");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
index 6b56e6017b15..7cfbb5a22316 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -136,9 +136,6 @@ public override MixedSubId Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId.");
-
return new MixedSubId(id);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null)
- throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId.");
-
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
index 76bffb1856bc..7186223e67b6 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -156,12 +156,6 @@ public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response.");
-
return new Model200Response(varClass, name);
}
@@ -189,14 +183,14 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo
///
public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
{
- if (model200Response.ClassOption.IsSet && model200Response.Class == null)
- throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response.");
-
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
if (model200Response.NameOption.IsSet)
- writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ if (model200Response.NameOption.Value != null)
+ writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ else
+ writer.WriteNull("name");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
index 7a982b8104d3..eeb350f4964f 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -136,9 +136,6 @@ public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (varClient.IsSet && varClient.Value == null)
- throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient.");
-
return new ModelClient(varClient);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
{
- if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null)
- throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient.");
-
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
index 100ccfa20e5b..86e07bbbbc4c 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
@@ -236,15 +236,6 @@ public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (varName.IsSet && varName.Value == null)
throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name.");
- if (property.IsSet && property.Value == null)
- throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name.");
-
- if (snakeCase.IsSet && snakeCase.Value == null)
- throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name.");
-
- if (var123Number.IsSet && var123Number.Value == null)
- throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name.");
-
return new Name(varName.Value!.Value!, property, snakeCase, var123Number);
}
@@ -272,19 +263,22 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
{
- if (name.PropertyOption.IsSet && name.Property == null)
- throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name.");
-
writer.WriteNumber("name", name.VarName);
if (name.PropertyOption.IsSet)
writer.WriteString("property", name.Property);
if (name.SnakeCaseOption.IsSet)
- writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ if (name.SnakeCaseOption.Value != null)
+ writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ else
+ writer.WriteNull("snake_case");
if (name.Var123NumberOption.IsSet)
- writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ if (name.Var123NumberOption.Value != null)
+ writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ else
+ writer.WriteNull("123Number");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
index db7eaa8f675c..f7ff8f69bb9e 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -366,12 +366,6 @@ public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass.");
-
- if (objectItemsNullable.IsSet && objectItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass.");
-
return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp);
}
@@ -399,12 +393,6 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J
///
public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass.");
-
- if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
-
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
index f7ae912c05e6..b315d41bb949 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -136,9 +136,6 @@ public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (justNumber.IsSet && justNumber.Value == null)
- throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly.");
-
return new NumberOnly(justNumber);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (numberOnly.JustNumberOption.IsSet)
- writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ if (numberOnly.JustNumberOption.Value != null)
+ writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ else
+ writer.WriteNull("JustNumber");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index fa4f88b3ecdd..1317bd91560c 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -199,18 +199,6 @@ public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReade
}
}
- if (bars.IsSet && bars.Value == null)
- throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (deprecatedRef.IsSet && deprecatedRef.Value == null)
- throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid);
}
@@ -238,15 +226,6 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj
///
public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
{
- if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
-
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
writer.WritePropertyName("bars");
@@ -258,7 +237,10 @@ public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields ob
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions);
}
if (objectWithDeprecatedFields.IdOption.IsSet)
- writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ if (objectWithDeprecatedFields.IdOption.Value != null)
+ writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (objectWithDeprecatedFields.UuidOption.IsSet)
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
index c4c43309bec1..bf0237990786 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
@@ -326,24 +326,6 @@ public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (complete.IsSet && complete.Value == null)
- throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order.");
-
- if (petId.IsSet && petId.Value == null)
- throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order.");
-
- if (quantity.IsSet && quantity.Value == null)
- throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order.");
-
- if (shipDate.IsSet && shipDate.Value == null)
- throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order.");
-
return new Order(complete, id, petId, quantity, shipDate, status);
}
@@ -372,19 +354,34 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
if (order.CompleteOption.IsSet)
- writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ if (order.CompleteOption.Value != null)
+ writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ else
+ writer.WriteNull("complete");
if (order.IdOption.IsSet)
- writer.WriteNumber("id", order.IdOption.Value!.Value);
+ if (order.IdOption.Value != null)
+ writer.WriteNumber("id", order.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (order.PetIdOption.IsSet)
- writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ if (order.PetIdOption.Value != null)
+ writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ else
+ writer.WriteNull("petId");
if (order.QuantityOption.IsSet)
- writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ if (order.QuantityOption.Value != null)
+ writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ else
+ writer.WriteNull("quantity");
if (order.ShipDateOption.IsSet)
- writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ if (order.ShipDateOption.Value != null)
+ writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ else
+ writer.WriteNull("shipDate");
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
index 4428479e0485..f9c6a1474bae 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -176,15 +176,6 @@ public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (myBoolean.IsSet && myBoolean.Value == null)
- throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite.");
-
- if (myNumber.IsSet && myNumber.Value == null)
- throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite.");
-
- if (myString.IsSet && myString.Value == null)
- throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite.");
-
return new OuterComposite(myBoolean, myNumber, myString);
}
@@ -212,14 +203,17 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
- if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
-
if (outerComposite.MyBooleanOption.IsSet)
- writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ if (outerComposite.MyBooleanOption.Value != null)
+ writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ else
+ writer.WriteNull("my_boolean");
if (outerComposite.MyNumberOption.IsSet)
- writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ if (outerComposite.MyNumberOption.Value != null)
+ writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ else
+ writer.WriteNull("my_number");
if (outerComposite.MyStringOption.IsSet)
writer.WriteString("my_string", outerComposite.MyString);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
index 56b981a0e2ad..9557747c46dc 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
@@ -319,18 +319,6 @@ public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (photoUrls.IsSet && photoUrls.Value == null)
throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet.");
- if (category.IsSet && category.Value == null)
- throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet.");
-
- if (tags.IsSet && tags.Value == null)
- throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet.");
-
return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags);
}
@@ -364,12 +352,6 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
if (pet.PhotoUrls == null)
throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
-
- if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
-
writer.WriteString("name", pet.Name);
writer.WritePropertyName("photoUrls");
@@ -380,7 +362,10 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions);
}
if (pet.IdOption.IsSet)
- writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ if (pet.IdOption.Value != null)
+ writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index a48fcb21dbef..17016304c4dd 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -194,12 +194,6 @@ public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst.");
-
- if (baz.IsSet && baz.Value == null)
- throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst.");
-
return new ReadOnlyFirst(bar, baz);
}
@@ -227,12 +221,6 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J
///
public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
{
- if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst.");
-
- if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
-
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
index 0c7dc7eab56f..ce661233c93b 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2079,39 +2079,6 @@ public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null)
throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
- if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass.");
-
- if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass.");
-
return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!);
}
@@ -2145,12 +2112,6 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
if (requiredClass.RequiredNotnullableStringProp == null)
throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
- if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
-
- if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
-
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
writer.WritePropertyName("required_notnullable_array_of_string");
@@ -2175,10 +2136,16 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp);
if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet)
- writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ if (requiredClass.NotRequiredNotnullableDatePropOption.Value != null)
+ writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ else
+ writer.WriteNull("not_required_notnullable_date_prop");
if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet)
- writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.Value != null)
+ writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ else
+ writer.WriteNull("not_required_notnullableinteger_prop");
if (requiredClass.NotRequiredNullableDatePropOption.IsSet)
if (requiredClass.NotRequiredNullableDatePropOption.Value != null)
@@ -2198,16 +2165,28 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions);
}
if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet)
- writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.Value != null)
+ writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_boolean_prop");
if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet)
- writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.Value != null)
+ writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ else
+ writer.WriteNull("notrequired_notnullable_datetime_prop");
if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer");
if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer_only");
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
@@ -2220,7 +2199,10 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp);
if (requiredClass.NotrequiredNotnullableUuidOption.IsSet)
- writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableUuidOption.Value != null)
+ writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_uuid");
if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet)
if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
index 6119748b2992..0c8e9be329f9 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
@@ -179,15 +179,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result.");
-
return new Result(code, data, uuid);
}
@@ -215,15 +206,6 @@ public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions)
{
- if (result.CodeOption.IsSet && result.Code == null)
- throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result.");
-
- if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
-
- if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
-
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
index 6276a3a8c8ae..752ea2da319e 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
@@ -191,12 +191,6 @@ public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (varLock.IsSet && varLock.Value == null)
throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return.");
- if (varReturn.IsSet && varReturn.Value == null)
- throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return.");
-
- if (varUnsafe.IsSet && varUnsafe.Value == null)
- throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return.");
-
return new Return(varLock.Value!, varAbstract.Value!, varReturn, varUnsafe);
}
@@ -227,9 +221,6 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
if (varReturn.Lock == null)
throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
- if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
-
writer.WriteString("lock", varReturn.Lock);
if (varReturn.Abstract != null)
@@ -238,7 +229,10 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
writer.WriteNull("abstract");
if (varReturn.VarReturnOption.IsSet)
- writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ if (varReturn.VarReturnOption.Value != null)
+ writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ else
+ writer.WriteNull("return");
if (varReturn.UnsafeOption.IsSet)
writer.WriteString("unsafe", varReturn.Unsafe);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index 245ea1053e5d..3219fdf99dde 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -156,12 +156,6 @@ public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (role.IsSet && role.Value == null)
- throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash.");
-
- if (roleUuid.IsSet && roleUuid.Value == null)
- throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash.");
-
return new RolesReportsHash(role, roleUuid);
}
@@ -189,16 +183,16 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null)
- throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash.");
-
if (rolesReportsHash.RoleOption.IsSet)
{
writer.WritePropertyName("role");
JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions);
}
if (rolesReportsHash.RoleUuidOption.IsSet)
- writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ if (rolesReportsHash.RoleUuidOption.Value != null)
+ writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ else
+ writer.WriteNull("role_uuid");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 684ca8e8b515..45e278a334ff 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -136,9 +136,6 @@ public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Typ
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole.");
-
return new RolesReportsHashRole(name);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null)
- throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole.");
-
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 1fce10cd7823..bd2b77eb5ce9 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -156,12 +156,6 @@ public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varSpecialModelName.IsSet && varSpecialModelName.Value == null)
- throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName.");
-
- if (specialPropertyName.IsSet && specialPropertyName.Value == null)
- throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName.");
-
return new SpecialModelName(varSpecialModelName, specialPropertyName);
}
@@ -189,14 +183,14 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN
///
public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
{
- if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null)
- throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName.");
-
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
if (specialModelName.SpecialPropertyNameOption.IsSet)
- writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ if (specialModelName.SpecialPropertyNameOption.Value != null)
+ writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ else
+ writer.WriteNull("$special[property.name]");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
index a6c404c940b8..089fc767f734 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
@@ -156,12 +156,6 @@ public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag.");
-
return new Tag(id, name);
}
@@ -189,11 +183,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
- if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
-
if (tag.IdOption.IsSet)
- writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ if (tag.IdOption.Value != null)
+ writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (tag.NameOption.IsSet)
writer.WriteString("name", tag.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index f1a1940574ee..5a0353bce33d 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -136,9 +136,6 @@ public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8Jso
}
}
- if (value.IsSet && value.Value == null)
- throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList.");
-
return new TestCollectionEndingWithWordList(value);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList.");
-
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index 5cbf9d28f57e..b86b7b610c6e 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -136,9 +136,6 @@ public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader u
}
}
- if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject.");
-
return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject.");
-
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
writer.WritePropertyName("TestCollectionEndingWithWordList");
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index 102413449b18..e626f9975ce5 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -136,9 +136,6 @@ public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonR
}
}
- if (someProperty.IsSet && someProperty.Value == null)
- throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest.");
-
return new TestInlineFreeformAdditionalPropertiesRequest(someProperty);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
{
- if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null)
- throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest.");
-
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
index e7829b5974ee..dfe6d8e7a887 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
@@ -180,15 +180,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult.");
-
return new TestResult(code, data, uuid);
}
@@ -216,12 +207,6 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
- if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
-
- if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
-
if (testResult.CodeOption.IsSet)
{
var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
index d02f765752fd..af12ad03e1bc 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
@@ -361,33 +361,6 @@ public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (email.IsSet && email.Value == null)
- throw new ArgumentNullException(nameof(email), "Property is not nullable for class User.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class User.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User.");
-
- if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null)
- throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User.");
-
- if (password.IsSet && password.Value == null)
- throw new ArgumentNullException(nameof(password), "Property is not nullable for class User.");
-
- if (phone.IsSet && phone.Value == null)
- throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User.");
-
- if (userStatus.IsSet && userStatus.Value == null)
- throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User.");
-
- if (username.IsSet && username.Value == null)
- throw new ArgumentNullException(nameof(username), "Property is not nullable for class User.");
-
return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username);
}
@@ -415,27 +388,6 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
{
- if (user.EmailOption.IsSet && user.Email == null)
- throw new ArgumentNullException(nameof(user.Email), "Property is required for class User.");
-
- if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
-
- if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
-
- if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
-
- if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
-
- if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
-
- if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
-
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
{
@@ -459,7 +411,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("firstName", user.FirstName);
if (user.IdOption.IsSet)
- writer.WriteNumber("id", user.IdOption.Value!.Value);
+ if (user.IdOption.Value != null)
+ writer.WriteNumber("id", user.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (user.LastNameOption.IsSet)
writer.WriteString("lastName", user.LastName);
@@ -484,7 +439,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("phone", user.Phone);
if (user.UserStatusOption.IsSet)
- writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ if (user.UserStatusOption.Value != null)
+ writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ else
+ writer.WriteNull("userStatus");
if (user.UsernameOption.IsSet)
writer.WriteString("username", user.Username);
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
index 3d5ad4a7d676..07d268952b5f 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
@@ -175,12 +175,6 @@ public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale.");
- if (hasBaleen.IsSet && hasBaleen.Value == null)
- throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale.");
-
- if (hasTeeth.IsSet && hasTeeth.Value == null)
- throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale.");
-
return new Whale(className.Value!, hasBaleen, hasTeeth);
}
@@ -214,10 +208,16 @@ public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOp
writer.WriteString("className", whale.ClassName);
if (whale.HasBaleenOption.IsSet)
- writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ if (whale.HasBaleenOption.Value != null)
+ writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ else
+ writer.WriteNull("hasBaleen");
if (whale.HasTeethOption.IsSet)
- writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ if (whale.HasTeethOption.Value != null)
+ writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ else
+ writer.WriteNull("hasTeeth");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
index 4ca12a36d096..716132325475 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
@@ -237,9 +237,6 @@ public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra.");
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra.");
-
return new Zebra(className.Value!, type);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index dfb395124397..59474730b6af 100644
--- a/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -204,9 +204,6 @@ public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null)
- throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass.");
-
return new ZeroBasedEnumClass(zeroBasedEnum);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Apple.cs
index dd3528fa42a4..0826aac5f1a9 100644
--- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -136,9 +136,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Banana.cs
index 170ad4b54dac..1cf95d5690f7 100644
--- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
index 056f2c03af8d..e1ad75e01636 100644
--- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -202,9 +202,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -241,9 +238,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Orange.cs b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Orange.cs
index eaa0165ba6c1..05777f379c18 100644
--- a/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Orange.cs
+++ b/samples/client/petstore/csharp/generichost/net10/OneOf/src/Org.OpenAPITools/Model/Orange.cs
@@ -136,9 +136,6 @@ public override Orange Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class Orange.");
-
return new Orange(sweet);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
if (orange.SweetOption.IsSet)
- writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
+ if (orange.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
index 65645b2e4829..e68030d8dfbe 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
@@ -137,9 +137,6 @@ public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
}
}
- if (activityOutputs.IsSet && activityOutputs.Value == null)
- throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity.");
-
return new Activity(activityOutputs);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
{
- if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null)
- throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity.");
-
if (activity.ActivityOutputsOption.IsSet)
{
writer.WritePropertyName("activity_outputs");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 728bbb0c349e..455cb9784010 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -157,12 +157,6 @@ public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8
}
}
- if (prop1.IsSet && prop1.Value == null)
- throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
- if (prop2.IsSet && prop2.Value == null)
- throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
return new ActivityOutputElementRepresentation(prop1, prop2);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent
///
public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
{
- if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation.");
-
- if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
-
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 9fa35476f70c..5d2b8f501bc5 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -278,27 +278,6 @@ public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader
}
}
- if (emptyMap.IsSet && emptyMap.Value == null)
- throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapProperty.IsSet && mapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass.");
-
return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString);
}
@@ -326,27 +305,6 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi
///
public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
-
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
index 37a0519bbd6b..ed53b38d189a 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
@@ -173,9 +173,6 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
-
return new Animal(color);
}
@@ -213,9 +210,6 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
{
- if (animal.ColorOption.IsSet && animal.Color == null)
- throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal.");
-
writer.WriteString("className", animal.ClassName);
if (animal.ColorOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
index bf92565f9a2e..ca3b2c1fdfd9 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -177,15 +177,6 @@ public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse.");
-
- if (message.IsSet && message.Value == null)
- throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse.");
-
return new ApiResponse(code, message, type);
}
@@ -213,14 +204,11 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
-
- if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
-
if (apiResponse.CodeOption.IsSet)
- writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ if (apiResponse.CodeOption.Value != null)
+ writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ else
+ writer.WriteNull("code");
if (apiResponse.MessageOption.IsSet)
writer.WriteString("message", apiResponse.Message);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
index 3dab90bbeb36..e1c0f65ea706 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
@@ -207,15 +207,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (colorCode.IsSet && colorCode.Value == null)
- throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple.");
-
- if (cultivar.IsSet && cultivar.Value == null)
- throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple.");
-
- if (origin.IsSet && origin.Value == null)
- throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple.");
-
return new Apple(colorCode, cultivar, origin);
}
@@ -243,15 +234,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.ColorCodeOption.IsSet && apple.ColorCode == null)
- throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple.");
-
- if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
-
- if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
-
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
index cbb5ea8f0849..c8344376a888 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -149,9 +149,6 @@ public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (cultivar.IsSet && cultivar.Value == null)
throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq.");
- if (mealy.IsSet && mealy.Value == null)
- throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq.");
-
return new AppleReq(cultivar.Value!, mealy);
}
@@ -185,7 +182,10 @@ public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerial
writer.WriteString("cultivar", appleReq.Cultivar);
if (appleReq.MealyOption.IsSet)
- writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ if (appleReq.MealyOption.Value != null)
+ writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ else
+ writer.WriteNull("mealy");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index cd3309a5900e..31072802633a 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -137,9 +137,6 @@ public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader,
}
}
- if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly.");
-
return new ArrayOfArrayOfNumberOnly(arrayArrayNumber);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly.");
-
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 90b6e4a8bd14..c605df6473f5 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -137,9 +137,6 @@ public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (arrayNumber.IsSet && arrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly.");
-
return new ArrayOfNumberOnly(arrayNumber);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly.");
-
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
index 6be410aad46e..33316827318d 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -177,15 +177,6 @@ public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
}
}
- if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest.");
-
- if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest.");
-
- if (arrayOfString.IsSet && arrayOfString.Value == null)
- throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest.");
-
return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString);
}
@@ -213,15 +204,6 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
-
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
writer.WritePropertyName("array_array_of_integer");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
index 1352e54c4091..74829deb5fb1 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
@@ -137,9 +137,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (lengthCm.IsSet && lengthCm.Value == null)
- throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana.");
-
return new Banana(lengthCm);
}
@@ -168,7 +165,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.LengthCmOption.IsSet)
- writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ if (banana.LengthCmOption.Value != null)
+ writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ else
+ writer.WriteNull("lengthCm");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
index 584505890fdc..0c9228dac974 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -149,9 +149,6 @@ public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
if (lengthCm.IsSet && lengthCm.Value == null)
throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq.");
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq.");
-
return new BananaReq(lengthCm.Value!.Value!, sweet);
}
@@ -182,7 +179,10 @@ public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeri
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
- writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ if (bananaReq.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
index e36a343dc5e2..7507fbf15047 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -238,24 +238,6 @@ public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (aTTNAME.IsSet && aTTNAME.Value == null)
- throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization.");
-
- if (capitalCamel.IsSet && capitalCamel.Value == null)
- throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization.");
-
- if (capitalSnake.IsSet && capitalSnake.Value == null)
- throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization.");
-
- if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null)
- throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization.");
-
- if (smallCamel.IsSet && smallCamel.Value == null)
- throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization.");
-
- if (smallSnake.IsSet && smallSnake.Value == null)
- throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization.");
-
return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake);
}
@@ -283,24 +265,6 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization,
///
public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
{
- if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null)
- throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
-
- if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
-
- if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
-
- if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
-
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
index 00b32d995aa3..2451fa64efcb 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
@@ -136,12 +136,6 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat.");
-
- if (declawed.IsSet && declawed.Value == null)
- throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat.");
-
return new Cat(color, declawed);
}
@@ -169,16 +163,16 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
{
- if (cat.ColorOption.IsSet && cat.Color == null)
- throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat.");
-
writer.WriteString("className", cat.ClassName);
if (cat.ColorOption.IsSet)
writer.WriteString("color", cat.Color);
if (cat.DeclawedOption.IsSet)
- writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ if (cat.DeclawedOption.Value != null)
+ writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ else
+ writer.WriteNull("declawed");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
index 0369f8f37e97..40e17252a708 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
@@ -153,9 +153,6 @@ public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (!name.IsSet)
throw new ArgumentException("Property is required for class Category.", nameof(name));
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category.");
-
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category.");
@@ -190,7 +187,10 @@ public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerial
throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
if (category.IdOption.IsSet)
- writer.WriteNumber("id", category.IdOption.Value!.Value);
+ if (category.IdOption.Value != null)
+ writer.WriteNumber("id", category.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
writer.WriteString("name", category.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
index 4131c59373af..219f38158e71 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -190,9 +190,6 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
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.");
@@ -223,9 +220,6 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
{
- if (childCat.NameOption.IsSet && childCat.Name == null)
- throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat.");
-
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
index e38fad89dbad..b29dc2232486 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -137,9 +137,6 @@ public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel.");
-
return new ClassModel(varClass);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
{
- if (classModel.ClassOption.IsSet && classModel.Class == null)
- throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel.");
-
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 8981331c9e19..cadefcdc9294 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -143,9 +143,6 @@ public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null)
- throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass.");
-
return new DateOnlyClass(dateOnlyProperty);
}
@@ -174,7 +171,10 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
- writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ if (dateOnlyClass.DateOnlyPropertyOption.Value != null)
+ writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ else
+ writer.WriteNull("dateOnlyProperty");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index 0b8716d11ff4..209ad029521a 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -137,9 +137,6 @@ public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject.");
-
return new DeprecatedObject(name);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj
///
public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null)
- throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject.");
-
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
index 6129b69ce916..eebabaf3da26 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
@@ -136,12 +136,6 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog.");
- if (breed.IsSet && breed.Value == null)
- throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog.");
-
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog.");
-
return new Dog(breed, color);
}
@@ -169,12 +163,6 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
{
- if (dog.BreedOption.IsSet && dog.Breed == null)
- throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog.");
-
- if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
-
writer.WriteString("className", dog.ClassName);
if (dog.BreedOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
index b6400a09e802..1ca6b42dead8 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
@@ -197,12 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (mainShape.IsSet && mainShape.Value == null)
- throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing.");
-
- if (shapes.IsSet && shapes.Value == null)
- throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing.");
-
return new Drawing(mainShape, nullableShape, shapeOrNull, shapes);
}
@@ -230,12 +224,6 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
{
- if (drawing.MainShapeOption.IsSet && drawing.MainShape == null)
- throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing.");
-
- if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
-
if (drawing.MainShapeOption.IsSet)
{
writer.WritePropertyName("mainShape");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
index 5c9774abc417..5a0ae3fe8c07 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -291,12 +291,6 @@ public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (arrayEnum.IsSet && arrayEnum.Value == null)
- throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays.");
-
- if (justSymbol.IsSet && justSymbol.Value == null)
- throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays.");
-
return new EnumArrays(arrayEnum, justSymbol);
}
@@ -324,9 +318,6 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
{
- if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null)
- throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays.");
-
if (enumArrays.ArrayEnumOption.IsSet)
{
writer.WritePropertyName("array_enum");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
index 897a9bd24efe..4c672d70aaf8 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -792,27 +792,6 @@ public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (enumStringRequired.IsSet && enumStringRequired.Value == null)
throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest.");
- if (enumInteger.IsSet && enumInteger.Value == null)
- throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest.");
-
- if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest.");
-
- if (enumNumber.IsSet && enumNumber.Value == null)
- throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest.");
-
- if (enumString.IsSet && enumString.Value == null)
- throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest.");
-
- if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest.");
-
- if (outerEnumInteger.IsSet && outerEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest.");
-
- if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest.");
-
return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue);
}
@@ -843,13 +822,22 @@ public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerial
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
- writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ if (enumTest.EnumIntegerOption.Value != null)
+ writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer");
if (enumTest.EnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ if (enumTest.EnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer_only");
if (enumTest.EnumNumberOption.IsSet)
- writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ if (enumTest.EnumNumberOption.Value != null)
+ writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ else
+ writer.WriteNull("enum_number");
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
writer.WriteString("enum_string", enumStringRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
index bdc5c25e1329..074dc96d0a9f 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
@@ -138,9 +138,6 @@ public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (sourceURI.IsSet && sourceURI.Value == null)
- throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File.");
-
return new File(sourceURI);
}
@@ -168,9 +165,6 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
{
- if (file.SourceURIOption.IsSet && file.SourceURI == null)
- throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File.");
-
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index d7c977f2fe4f..f5681591bd7f 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -157,12 +157,6 @@ public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (file.IsSet && file.Value == null)
- throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass.");
-
- if (files.IsSet && files.Value == null)
- throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass.");
-
return new FileSchemaTestClass(file, files);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema
///
public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass.");
-
- if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
-
if (fileSchemaTestClass.FileOption.IsSet)
{
writer.WritePropertyName("file");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
index ac4aeb49df5c..d68007dd2828 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
@@ -137,9 +137,6 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
-
return new Foo(bar);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
- if (foo.BarOption.IsSet && foo.Bar == null)
- throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");
-
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 9f57f4d6318a..bc458b1bd4fe 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -137,9 +137,6 @@ public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Ty
}
}
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse.");
-
return new FooGetDefaultResponse(varString);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe
///
public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null)
- throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse.");
-
if (fooGetDefaultResponse.StringOption.IsSet)
{
writer.WritePropertyName("string");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
index 3daacf80952d..f00f123ade8b 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -848,75 +848,6 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (stringFormattedAsDecimalRequired.IsSet && stringFormattedAsDecimalRequired.Value == null)
throw new ArgumentNullException(nameof(stringFormattedAsDecimalRequired), "Property is not nullable for class FormatTest.");
- if (binary.IsSet && binary.Value == null)
- throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest.");
-
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest.");
-
- if (varDecimal.IsSet && varDecimal.Value == null)
- throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest.");
-
- if (varDouble.IsSet && varDouble.Value == null)
- throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName2.IsSet && duplicatePropertyName2.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName2), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName.IsSet && duplicatePropertyName.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName), "Property is not nullable for class FormatTest.");
-
- if (varFloat.IsSet && varFloat.Value == null)
- throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest.");
-
- if (int32.IsSet && int32.Value == null)
- throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest.");
-
- if (int32Range.IsSet && int32Range.Value == null)
- throw new ArgumentNullException(nameof(int32Range), "Property is not nullable for class FormatTest.");
-
- if (int64.IsSet && int64.Value == null)
- throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest.");
-
- if (int64Negative.IsSet && int64Negative.Value == null)
- throw new ArgumentNullException(nameof(int64Negative), "Property is not nullable for class FormatTest.");
-
- if (int64NegativeExclusive.IsSet && int64NegativeExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64NegativeExclusive), "Property is not nullable for class FormatTest.");
-
- if (int64Positive.IsSet && int64Positive.Value == null)
- throw new ArgumentNullException(nameof(int64Positive), "Property is not nullable for class FormatTest.");
-
- if (int64PositiveExclusive.IsSet && int64PositiveExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64PositiveExclusive), "Property is not nullable for class FormatTest.");
-
- if (integer.IsSet && integer.Value == null)
- throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest.");
-
- if (patternWithBackslash.IsSet && patternWithBackslash.Value == null)
- throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigits.IsSet && patternWithDigits.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest.");
-
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest.");
-
- if (stringFormattedAsDecimal.IsSet && stringFormattedAsDecimal.Value == null)
- throw new ArgumentNullException(nameof(stringFormattedAsDecimal), "Property is not nullable for class FormatTest.");
-
- if (unsignedInteger.IsSet && unsignedInteger.Value == null)
- throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest.");
-
- if (unsignedLong.IsSet && unsignedLong.Value == null)
- throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
-
return new FormatTest(varByte.Value!, date.Value!.Value!, number.Value!.Value!, password.Value!, stringFormattedAsDecimalRequired.Value!.Value!, binary, dateTime, varDecimal, varDouble, duplicatePropertyName2, duplicatePropertyName, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, stringFormattedAsDecimal, unsignedInteger, unsignedLong, uuid);
}
@@ -950,27 +881,6 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
if (formatTest.Password == null)
throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
-
- if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
-
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
@@ -987,7 +897,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions);
}
if (formatTest.DateTimeOption.IsSet)
- writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (formatTest.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (formatTest.DecimalOption.IsSet)
{
@@ -995,7 +908,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions);
}
if (formatTest.DoubleOption.IsSet)
- writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ if (formatTest.DoubleOption.Value != null)
+ writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ else
+ writer.WriteNull("double");
if (formatTest.DuplicatePropertyName2Option.IsSet)
writer.WriteString("duplicate_property_name", formatTest.DuplicatePropertyName2);
@@ -1004,31 +920,58 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("@duplicate_property_name", formatTest.DuplicatePropertyName);
if (formatTest.FloatOption.IsSet)
- writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ if (formatTest.FloatOption.Value != null)
+ writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ else
+ writer.WriteNull("float");
if (formatTest.Int32Option.IsSet)
- writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ if (formatTest.Int32Option.Value != null)
+ writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ else
+ writer.WriteNull("int32");
if (formatTest.Int32RangeOption.IsSet)
- writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ if (formatTest.Int32RangeOption.Value != null)
+ writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ else
+ writer.WriteNull("int32Range");
if (formatTest.Int64Option.IsSet)
- writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ if (formatTest.Int64Option.Value != null)
+ writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ else
+ writer.WriteNull("int64");
if (formatTest.Int64NegativeOption.IsSet)
- writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ if (formatTest.Int64NegativeOption.Value != null)
+ writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ else
+ writer.WriteNull("int64Negative");
if (formatTest.Int64NegativeExclusiveOption.IsSet)
- writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ if (formatTest.Int64NegativeExclusiveOption.Value != null)
+ writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64NegativeExclusive");
if (formatTest.Int64PositiveOption.IsSet)
- writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ if (formatTest.Int64PositiveOption.Value != null)
+ writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64Positive");
if (formatTest.Int64PositiveExclusiveOption.IsSet)
- writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ if (formatTest.Int64PositiveExclusiveOption.Value != null)
+ writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64PositiveExclusive");
if (formatTest.IntegerOption.IsSet)
- writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ if (formatTest.IntegerOption.Value != null)
+ writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ else
+ writer.WriteNull("integer");
if (formatTest.PatternWithBackslashOption.IsSet)
writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash);
@@ -1043,16 +986,28 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("string", formatTest.String);
if (formatTest.StringFormattedAsDecimalOption.IsSet)
- writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ if (formatTest.StringFormattedAsDecimalOption.Value != null)
+ writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ else
+ writer.WriteNull("string_formatted_as_decimal");
if (formatTest.UnsignedIntegerOption.IsSet)
- writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ if (formatTest.UnsignedIntegerOption.Value != null)
+ writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_integer");
if (formatTest.UnsignedLongOption.IsSet)
- writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ if (formatTest.UnsignedLongOption.Value != null)
+ writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_long");
if (formatTest.UuidOption.IsSet)
- writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ if (formatTest.UuidOption.Value != null)
+ writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
index 6aa166222089..de97c93e546a 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
@@ -175,9 +175,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -211,9 +208,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
index 8b41879612ea..b13b4b826059 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -179,9 +179,6 @@ public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -228,9 +225,6 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (gmFruit.ColorOption.IsSet && gmFruit.Color == null)
- throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit.");
-
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index 0bf77a18dca2..680d39774424 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -198,12 +198,6 @@ public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typ
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly.");
-
- if (foo.IsSet && foo.Value == null)
- throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly.");
-
return new HasOnlyReadOnly(bar, foo);
}
@@ -231,12 +225,6 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl
///
public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly.");
-
- if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
-
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
index 024998ed763a..a15f8babfebd 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
@@ -137,9 +137,6 @@ public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (var123List.IsSet && var123List.Value == null)
- throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List.");
-
return new List(var123List);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
{
- if (list.Var123ListOption.IsSet && list.Var123List == null)
- throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List.");
-
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e54eebdaa1dc..bfefac8c977f 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -157,12 +157,6 @@ public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (escapedLiteralString.IsSet && escapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
- if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
return new LiteralStringClass(escapedLiteralString, unescapedLiteralString);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri
///
public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass.");
-
- if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
-
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
index 40dee3f15569..775fe4599442 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
@@ -263,18 +263,6 @@ public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (directMap.IsSet && directMap.Value == null)
- throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest.");
-
- if (indirectMap.IsSet && indirectMap.Value == null)
- throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest.");
-
- if (mapMapOfString.IsSet && mapMapOfString.Value == null)
- throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest.");
-
- if (mapOfEnumString.IsSet && mapOfEnumString.Value == null)
- throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest.");
-
return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString);
}
@@ -302,18 +290,6 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest.");
-
- if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
-
- if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
-
- if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
-
if (mapTest.DirectMapOption.IsSet)
{
writer.WritePropertyName("direct_map");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index cdac03c3bcf4..b7562da53ca1 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -137,9 +137,6 @@ public override MixedAnyOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf.");
-
return new MixedAnyOf(content);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null)
- throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf.");
-
if (mixedAnyOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
index e9f36662dd80..cf8a31520783 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -137,9 +137,6 @@ public override MixedOneOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf.");
-
return new MixedOneOf(content);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null)
- throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf.");
-
if (mixedOneOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3629d644571b..fcfbae83d506 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -209,18 +209,6 @@ public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonRea
}
}
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (map.IsSet && map.Value == null)
- throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuidWithPattern.IsSet && uuidWithPattern.Value == null)
- throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern);
}
@@ -248,11 +236,11 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
-
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
- writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet)
{
@@ -260,10 +248,16 @@ public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalP
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions);
}
if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet)
- writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value != null)
+ writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet)
- writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value != null)
+ writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ else
+ writer.WriteNull("uuid_with_pattern");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
index 696681a920f3..daae5ac2d835 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -137,9 +137,6 @@ public override MixedSubId Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId.");
-
return new MixedSubId(id);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null)
- throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId.");
-
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
index 4b3f421263d4..bf378de647bc 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -157,12 +157,6 @@ public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response.");
-
return new Model200Response(varClass, name);
}
@@ -190,14 +184,14 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo
///
public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
{
- if (model200Response.ClassOption.IsSet && model200Response.Class == null)
- throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response.");
-
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
if (model200Response.NameOption.IsSet)
- writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ if (model200Response.NameOption.Value != null)
+ writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ else
+ writer.WriteNull("name");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
index 49dcb68c571f..06d54d89c068 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -137,9 +137,6 @@ public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (varClient.IsSet && varClient.Value == null)
- throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient.");
-
return new ModelClient(varClient);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
{
- if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null)
- throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient.");
-
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
index 72938274943d..9536a8c463c1 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
@@ -237,15 +237,6 @@ public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (varName.IsSet && varName.Value == null)
throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name.");
- if (property.IsSet && property.Value == null)
- throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name.");
-
- if (snakeCase.IsSet && snakeCase.Value == null)
- throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name.");
-
- if (var123Number.IsSet && var123Number.Value == null)
- throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name.");
-
return new Name(varName.Value!.Value!, property, snakeCase, var123Number);
}
@@ -273,19 +264,22 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
{
- if (name.PropertyOption.IsSet && name.Property == null)
- throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name.");
-
writer.WriteNumber("name", name.VarName);
if (name.PropertyOption.IsSet)
writer.WriteString("property", name.Property);
if (name.SnakeCaseOption.IsSet)
- writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ if (name.SnakeCaseOption.Value != null)
+ writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ else
+ writer.WriteNull("snake_case");
if (name.Var123NumberOption.IsSet)
- writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ if (name.Var123NumberOption.Value != null)
+ writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ else
+ writer.WriteNull("123Number");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
index aa2baca6ee31..0158c4f696ad 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -367,12 +367,6 @@ public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass.");
-
- if (objectItemsNullable.IsSet && objectItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass.");
-
return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp);
}
@@ -400,12 +394,6 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J
///
public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass.");
-
- if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
-
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
index 3662647e6562..0604d74f5677 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -137,9 +137,6 @@ public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (justNumber.IsSet && justNumber.Value == null)
- throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly.");
-
return new NumberOnly(justNumber);
}
@@ -168,7 +165,10 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (numberOnly.JustNumberOption.IsSet)
- writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ if (numberOnly.JustNumberOption.Value != null)
+ writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ else
+ writer.WriteNull("JustNumber");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index b2fced877576..d0146bbf4380 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -200,18 +200,6 @@ public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReade
}
}
- if (bars.IsSet && bars.Value == null)
- throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (deprecatedRef.IsSet && deprecatedRef.Value == null)
- throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid);
}
@@ -239,15 +227,6 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj
///
public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
{
- if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
-
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
writer.WritePropertyName("bars");
@@ -259,7 +238,10 @@ public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields ob
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions);
}
if (objectWithDeprecatedFields.IdOption.IsSet)
- writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ if (objectWithDeprecatedFields.IdOption.Value != null)
+ writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (objectWithDeprecatedFields.UuidOption.IsSet)
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
index fff55dc03b4b..22adf3949caf 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
@@ -327,24 +327,6 @@ public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (complete.IsSet && complete.Value == null)
- throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order.");
-
- if (petId.IsSet && petId.Value == null)
- throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order.");
-
- if (quantity.IsSet && quantity.Value == null)
- throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order.");
-
- if (shipDate.IsSet && shipDate.Value == null)
- throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order.");
-
return new Order(complete, id, petId, quantity, shipDate, status);
}
@@ -373,19 +355,34 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
if (order.CompleteOption.IsSet)
- writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ if (order.CompleteOption.Value != null)
+ writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ else
+ writer.WriteNull("complete");
if (order.IdOption.IsSet)
- writer.WriteNumber("id", order.IdOption.Value!.Value);
+ if (order.IdOption.Value != null)
+ writer.WriteNumber("id", order.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (order.PetIdOption.IsSet)
- writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ if (order.PetIdOption.Value != null)
+ writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ else
+ writer.WriteNull("petId");
if (order.QuantityOption.IsSet)
- writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ if (order.QuantityOption.Value != null)
+ writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ else
+ writer.WriteNull("quantity");
if (order.ShipDateOption.IsSet)
- writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ if (order.ShipDateOption.Value != null)
+ writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ else
+ writer.WriteNull("shipDate");
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
index 834a7f3516f1..77807c15742c 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -177,15 +177,6 @@ public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (myBoolean.IsSet && myBoolean.Value == null)
- throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite.");
-
- if (myNumber.IsSet && myNumber.Value == null)
- throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite.");
-
- if (myString.IsSet && myString.Value == null)
- throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite.");
-
return new OuterComposite(myBoolean, myNumber, myString);
}
@@ -213,14 +204,17 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
- if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
-
if (outerComposite.MyBooleanOption.IsSet)
- writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ if (outerComposite.MyBooleanOption.Value != null)
+ writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ else
+ writer.WriteNull("my_boolean");
if (outerComposite.MyNumberOption.IsSet)
- writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ if (outerComposite.MyNumberOption.Value != null)
+ writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ else
+ writer.WriteNull("my_number");
if (outerComposite.MyStringOption.IsSet)
writer.WriteString("my_string", outerComposite.MyString);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
index fc68eb27a177..8dafe7f105ae 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
@@ -320,18 +320,6 @@ public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (photoUrls.IsSet && photoUrls.Value == null)
throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet.");
- if (category.IsSet && category.Value == null)
- throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet.");
-
- if (tags.IsSet && tags.Value == null)
- throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet.");
-
return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags);
}
@@ -365,12 +353,6 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
if (pet.PhotoUrls == null)
throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
-
- if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
-
writer.WriteString("name", pet.Name);
writer.WritePropertyName("photoUrls");
@@ -381,7 +363,10 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions);
}
if (pet.IdOption.IsSet)
- writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ if (pet.IdOption.Value != null)
+ writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 4d458434bb1c..cf6451028c6e 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -195,12 +195,6 @@ public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst.");
-
- if (baz.IsSet && baz.Value == null)
- throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst.");
-
return new ReadOnlyFirst(bar, baz);
}
@@ -228,12 +222,6 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J
///
public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
{
- if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst.");
-
- if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
-
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
index 074d0e77ee37..f4c4908b2237 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2080,39 +2080,6 @@ public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null)
throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
- if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass.");
-
- if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass.");
-
return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!);
}
@@ -2146,12 +2113,6 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
if (requiredClass.RequiredNotnullableStringProp == null)
throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
- if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
-
- if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
-
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
writer.WritePropertyName("required_notnullable_array_of_string");
@@ -2176,10 +2137,16 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp);
if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet)
- writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ if (requiredClass.NotRequiredNotnullableDatePropOption.Value != null)
+ writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ else
+ writer.WriteNull("not_required_notnullable_date_prop");
if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet)
- writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.Value != null)
+ writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ else
+ writer.WriteNull("not_required_notnullableinteger_prop");
if (requiredClass.NotRequiredNullableDatePropOption.IsSet)
if (requiredClass.NotRequiredNullableDatePropOption.Value != null)
@@ -2199,16 +2166,28 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions);
}
if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet)
- writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.Value != null)
+ writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_boolean_prop");
if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet)
- writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.Value != null)
+ writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ else
+ writer.WriteNull("notrequired_notnullable_datetime_prop");
if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer");
if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer_only");
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
@@ -2221,7 +2200,10 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp);
if (requiredClass.NotrequiredNotnullableUuidOption.IsSet)
- writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableUuidOption.Value != null)
+ writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_uuid");
if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet)
if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
index 1c1f18fd1dec..5ce641729926 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
@@ -180,15 +180,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result.");
-
return new Result(code, data, uuid);
}
@@ -216,15 +207,6 @@ public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions)
{
- if (result.CodeOption.IsSet && result.Code == null)
- throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result.");
-
- if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
-
- if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
-
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
index 1544a23710c1..81617782b527 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
@@ -192,12 +192,6 @@ public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (varLock.IsSet && varLock.Value == null)
throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return.");
- if (varReturn.IsSet && varReturn.Value == null)
- throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return.");
-
- if (varUnsafe.IsSet && varUnsafe.Value == null)
- throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return.");
-
return new Return(varLock.Value!, varAbstract.Value!, varReturn, varUnsafe);
}
@@ -228,9 +222,6 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
if (varReturn.Lock == null)
throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
- if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
-
writer.WriteString("lock", varReturn.Lock);
if (varReturn.Abstract != null)
@@ -239,7 +230,10 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
writer.WriteNull("abstract");
if (varReturn.VarReturnOption.IsSet)
- writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ if (varReturn.VarReturnOption.Value != null)
+ writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ else
+ writer.WriteNull("return");
if (varReturn.UnsafeOption.IsSet)
writer.WriteString("unsafe", varReturn.Unsafe);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index 28b65b24ecf3..782fe80540e1 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -157,12 +157,6 @@ public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (role.IsSet && role.Value == null)
- throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash.");
-
- if (roleUuid.IsSet && roleUuid.Value == null)
- throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash.");
-
return new RolesReportsHash(role, roleUuid);
}
@@ -190,16 +184,16 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null)
- throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash.");
-
if (rolesReportsHash.RoleOption.IsSet)
{
writer.WritePropertyName("role");
JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions);
}
if (rolesReportsHash.RoleUuidOption.IsSet)
- writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ if (rolesReportsHash.RoleUuidOption.Value != null)
+ writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ else
+ writer.WriteNull("role_uuid");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index ba4ac84d8e20..c723f857b80e 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -137,9 +137,6 @@ public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Typ
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole.");
-
return new RolesReportsHashRole(name);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null)
- throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole.");
-
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 0cf9332983fd..f054cff9e4ea 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -157,12 +157,6 @@ public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varSpecialModelName.IsSet && varSpecialModelName.Value == null)
- throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName.");
-
- if (specialPropertyName.IsSet && specialPropertyName.Value == null)
- throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName.");
-
return new SpecialModelName(varSpecialModelName, specialPropertyName);
}
@@ -190,14 +184,14 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN
///
public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
{
- if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null)
- throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName.");
-
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
if (specialModelName.SpecialPropertyNameOption.IsSet)
- writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ if (specialModelName.SpecialPropertyNameOption.Value != null)
+ writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ else
+ writer.WriteNull("$special[property.name]");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
index a350814f2c88..a5735f5f5452 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
@@ -157,12 +157,6 @@ public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag.");
-
return new Tag(id, name);
}
@@ -190,11 +184,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
- if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
-
if (tag.IdOption.IsSet)
- writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ if (tag.IdOption.Value != null)
+ writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (tag.NameOption.IsSet)
writer.WriteString("name", tag.Name);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index b5f8d88ed68d..4ffddf1d1aef 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -137,9 +137,6 @@ public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8Jso
}
}
- if (value.IsSet && value.Value == null)
- throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList.");
-
return new TestCollectionEndingWithWordList(value);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList.");
-
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index 37acae1c88df..d58f1e6dc695 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -137,9 +137,6 @@ public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader u
}
}
- if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject.");
-
return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject.");
-
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
writer.WritePropertyName("TestCollectionEndingWithWordList");
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index de60d7c2281f..b9052313836c 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -137,9 +137,6 @@ public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonR
}
}
- if (someProperty.IsSet && someProperty.Value == null)
- throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest.");
-
return new TestInlineFreeformAdditionalPropertiesRequest(someProperty);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
{
- if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null)
- throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest.");
-
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
index df0deacac70e..d7310e182744 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
@@ -181,15 +181,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult.");
-
return new TestResult(code, data, uuid);
}
@@ -217,12 +208,6 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
- if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
-
- if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
-
if (testResult.CodeOption.IsSet)
{
var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
index 6af3ab9df35c..4a72b6988ae5 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
@@ -362,33 +362,6 @@ public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (email.IsSet && email.Value == null)
- throw new ArgumentNullException(nameof(email), "Property is not nullable for class User.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class User.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User.");
-
- if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null)
- throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User.");
-
- if (password.IsSet && password.Value == null)
- throw new ArgumentNullException(nameof(password), "Property is not nullable for class User.");
-
- if (phone.IsSet && phone.Value == null)
- throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User.");
-
- if (userStatus.IsSet && userStatus.Value == null)
- throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User.");
-
- if (username.IsSet && username.Value == null)
- throw new ArgumentNullException(nameof(username), "Property is not nullable for class User.");
-
return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username);
}
@@ -416,27 +389,6 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
{
- if (user.EmailOption.IsSet && user.Email == null)
- throw new ArgumentNullException(nameof(user.Email), "Property is required for class User.");
-
- if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
-
- if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
-
- if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
-
- if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
-
- if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
-
- if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
-
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
{
@@ -460,7 +412,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("firstName", user.FirstName);
if (user.IdOption.IsSet)
- writer.WriteNumber("id", user.IdOption.Value!.Value);
+ if (user.IdOption.Value != null)
+ writer.WriteNumber("id", user.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (user.LastNameOption.IsSet)
writer.WriteString("lastName", user.LastName);
@@ -485,7 +440,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("phone", user.Phone);
if (user.UserStatusOption.IsSet)
- writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ if (user.UserStatusOption.Value != null)
+ writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ else
+ writer.WriteNull("userStatus");
if (user.UsernameOption.IsSet)
writer.WriteString("username", user.Username);
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
index 080a4f804022..2aa92b38bcca 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
@@ -176,12 +176,6 @@ public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale.");
- if (hasBaleen.IsSet && hasBaleen.Value == null)
- throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale.");
-
- if (hasTeeth.IsSet && hasTeeth.Value == null)
- throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale.");
-
return new Whale(className.Value!, hasBaleen, hasTeeth);
}
@@ -215,10 +209,16 @@ public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOp
writer.WriteString("className", whale.ClassName);
if (whale.HasBaleenOption.IsSet)
- writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ if (whale.HasBaleenOption.Value != null)
+ writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ else
+ writer.WriteNull("hasBaleen");
if (whale.HasTeethOption.IsSet)
- writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ if (whale.HasTeethOption.Value != null)
+ writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ else
+ writer.WriteNull("hasTeeth");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
index 0d0e7222c42b..297c28839930 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
@@ -238,9 +238,6 @@ public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra.");
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra.");
-
return new Zebra(className.Value!, type);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 74792442fd0e..8976bef3505e 100644
--- a/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net10/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -205,9 +205,6 @@ public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null)
- throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass.");
-
return new ZeroBasedEnumClass(zeroBasedEnum);
}
diff --git a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
index d81a3689e6e1..d2d90cc36c59 100644
--- a/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net10/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
@@ -158,12 +158,6 @@ public override NowGet200Response Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (now.IsSet && now.Value == null)
- throw new ArgumentNullException(nameof(now), "Property is not nullable for class NowGet200Response.");
-
- if (today.IsSet && today.Value == null)
- throw new ArgumentNullException(nameof(today), "Property is not nullable for class NowGet200Response.");
-
return new NowGet200Response(now, today);
}
@@ -192,10 +186,16 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
if (nowGet200Response.NowOption.IsSet)
- writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
+ if (nowGet200Response.NowOption.Value != null)
+ writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
+ else
+ writer.WriteNull("now");
if (nowGet200Response.TodayOption.IsSet)
- writer.WriteString("today", nowGet200Response.TodayOption.Value!.Value.ToString(TodayFormat));
+ if (nowGet200Response.TodayOption.Value != null)
+ writer.WriteString("today", nowGet200Response.TodayOption.Value!.Value.ToString(TodayFormat));
+ else
+ writer.WriteNull("today");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs
index e5c016d2627d..c1770389a70b 100644
--- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Adult.cs
@@ -134,18 +134,6 @@ public override Adult Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (children.IsSet && children.Value == null)
- throw new ArgumentNullException(nameof(children), "Property is not nullable for class Adult.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Adult.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Adult.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Adult.");
-
return new Adult(children, firstName, lastName);
}
@@ -173,15 +161,6 @@ public override void Write(Utf8JsonWriter writer, Adult adult, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions)
{
- if (adult.ChildrenOption.IsSet && adult.Children == null)
- throw new ArgumentNullException(nameof(adult.Children), "Property is required for class Adult.");
-
- if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
-
- if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
-
if (adult.ChildrenOption.IsSet)
{
writer.WritePropertyName("children");
diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs
index 94cfd4f4aa62..7a142b9ac41e 100644
--- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Child.cs
@@ -154,21 +154,6 @@ public override Child Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (age.IsSet && age.Value == null)
- throw new ArgumentNullException(nameof(age), "Property is not nullable for class Child.");
-
- if (boosterSeat.IsSet && boosterSeat.Value == null)
- throw new ArgumentNullException(nameof(boosterSeat), "Property is not nullable for class Child.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Child.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Child.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Child.");
-
return new Child(age, boosterSeat, firstName, lastName);
}
@@ -196,17 +181,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
- if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
-
- if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
-
if (child.AgeOption.IsSet)
- writer.WriteNumber("age", child.AgeOption.Value!.Value);
+ if (child.AgeOption.Value != null)
+ writer.WriteNumber("age", child.AgeOption.Value!.Value);
+ else
+ writer.WriteNull("age");
if (child.BoosterSeatOption.IsSet)
- writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value);
+ if (child.BoosterSeatOption.Value != null)
+ writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value);
+ else
+ writer.WriteNull("boosterSeat");
if (child.FirstNameOption.IsSet)
writer.WriteString("firstName", child.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs
index 6da989d4e3a7..a9dedb4eb4f0 100644
--- a/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AllOf/src/Org.OpenAPITools/Model/Person.cs
@@ -186,15 +186,6 @@ public override Person Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Person.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Person.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Person.");
-
return new Person(firstName, lastName);
}
@@ -232,12 +223,6 @@ public override void Write(Utf8JsonWriter writer, Person person, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions)
{
- if (person.FirstNameOption.IsSet && person.FirstName == null)
- throw new ArgumentNullException(nameof(person.FirstName), "Property is required for class Person.");
-
- if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
-
if (person.FirstNameOption.IsSet)
writer.WriteString("firstName", person.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
index dd3528fa42a4..0826aac5f1a9 100644
--- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -136,9 +136,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
index 170ad4b54dac..1cf95d5690f7 100644
--- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
index 89b223fa5dbb..480e908afc63 100644
--- a/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -185,9 +185,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -234,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
index 8531edebf731..d51f01d8357e 100644
--- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
@@ -135,9 +135,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -165,9 +162,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
index 93897bf0b56a..1f90d47f25d4 100644
--- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
@@ -135,9 +135,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -166,7 +163,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
index 60e3c31c6a4f..b53b9cc8694d 100644
--- a/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
@@ -184,9 +184,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -233,9 +230,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
index fd37515f54a2..54a14058a611 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
@@ -136,9 +136,6 @@ public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
}
}
- if (activityOutputs.IsSet && activityOutputs.Value == null)
- throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity.");
-
return new Activity(activityOutputs);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
{
- if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null)
- throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity.");
-
if (activity.ActivityOutputsOption.IsSet)
{
writer.WritePropertyName("activity_outputs");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 80ab5ec04b8d..29e3444ae64f 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -156,12 +156,6 @@ public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8
}
}
- if (prop1.IsSet && prop1.Value == null)
- throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
- if (prop2.IsSet && prop2.Value == null)
- throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
return new ActivityOutputElementRepresentation(prop1, prop2);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent
///
public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
{
- if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation.");
-
- if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
-
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index de2cf7f84849..f56f4f0806fc 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -277,27 +277,6 @@ public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader
}
}
- if (emptyMap.IsSet && emptyMap.Value == null)
- throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapProperty.IsSet && mapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass.");
-
return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString);
}
@@ -325,27 +304,6 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi
///
public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
-
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
index 1e87e6de2950..4d36ec4ce4d4 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
@@ -172,9 +172,6 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
-
return new Animal(color);
}
@@ -212,9 +209,6 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
{
- if (animal.ColorOption.IsSet && animal.Color == null)
- throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal.");
-
writer.WriteString("className", animal.ClassName);
if (animal.ColorOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
index c7fa501c3c5d..65aa7bce8814 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -176,15 +176,6 @@ public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse.");
-
- if (message.IsSet && message.Value == null)
- throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse.");
-
return new ApiResponse(code, message, type);
}
@@ -212,14 +203,11 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
-
- if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
-
if (apiResponse.CodeOption.IsSet)
- writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ if (apiResponse.CodeOption.Value != null)
+ writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ else
+ writer.WriteNull("code");
if (apiResponse.MessageOption.IsSet)
writer.WriteString("message", apiResponse.Message);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
index 601dae95aa1a..233780d0bbf9 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
@@ -206,15 +206,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (colorCode.IsSet && colorCode.Value == null)
- throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple.");
-
- if (cultivar.IsSet && cultivar.Value == null)
- throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple.");
-
- if (origin.IsSet && origin.Value == null)
- throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple.");
-
return new Apple(colorCode, cultivar, origin);
}
@@ -242,15 +233,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.ColorCodeOption.IsSet && apple.ColorCode == null)
- throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple.");
-
- if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
-
- if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
-
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
index fdef147cb388..603ed8b1b7c8 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -148,9 +148,6 @@ public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (cultivar.IsSet && cultivar.Value == null)
throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq.");
- if (mealy.IsSet && mealy.Value == null)
- throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq.");
-
return new AppleReq(cultivar.Value!, mealy);
}
@@ -184,7 +181,10 @@ public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerial
writer.WriteString("cultivar", appleReq.Cultivar);
if (appleReq.MealyOption.IsSet)
- writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ if (appleReq.MealyOption.Value != null)
+ writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ else
+ writer.WriteNull("mealy");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index a09872cef811..e32622955178 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -136,9 +136,6 @@ public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader,
}
}
- if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly.");
-
return new ArrayOfArrayOfNumberOnly(arrayArrayNumber);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly.");
-
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index c338f29efc9d..31f190ea0bd6 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -136,9 +136,6 @@ public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (arrayNumber.IsSet && arrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly.");
-
return new ArrayOfNumberOnly(arrayNumber);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly.");
-
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
index 04609b245365..2543e616837a 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -176,15 +176,6 @@ public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
}
}
- if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest.");
-
- if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest.");
-
- if (arrayOfString.IsSet && arrayOfString.Value == null)
- throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest.");
-
return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString);
}
@@ -212,15 +203,6 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
-
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
writer.WritePropertyName("array_array_of_integer");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
index cf0ee9cdb1aa..19d507f22d49 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (lengthCm.IsSet && lengthCm.Value == null)
- throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana.");
-
return new Banana(lengthCm);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.LengthCmOption.IsSet)
- writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ if (banana.LengthCmOption.Value != null)
+ writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ else
+ writer.WriteNull("lengthCm");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
index 10375771f80b..e53a11f03ac0 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -148,9 +148,6 @@ public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
if (lengthCm.IsSet && lengthCm.Value == null)
throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq.");
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq.");
-
return new BananaReq(lengthCm.Value!.Value!, sweet);
}
@@ -181,7 +178,10 @@ public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeri
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
- writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ if (bananaReq.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
index 133845a991f0..d23f06b49376 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -237,24 +237,6 @@ public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (aTTNAME.IsSet && aTTNAME.Value == null)
- throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization.");
-
- if (capitalCamel.IsSet && capitalCamel.Value == null)
- throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization.");
-
- if (capitalSnake.IsSet && capitalSnake.Value == null)
- throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization.");
-
- if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null)
- throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization.");
-
- if (smallCamel.IsSet && smallCamel.Value == null)
- throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization.");
-
- if (smallSnake.IsSet && smallSnake.Value == null)
- throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization.");
-
return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake);
}
@@ -282,24 +264,6 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization,
///
public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
{
- if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null)
- throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
-
- if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
-
- if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
-
- if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
-
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
index 4887c6c7aff7..6933fd651942 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
@@ -135,12 +135,6 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat.");
-
- if (declawed.IsSet && declawed.Value == null)
- throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat.");
-
return new Cat(color, declawed);
}
@@ -168,16 +162,16 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
{
- if (cat.ColorOption.IsSet && cat.Color == null)
- throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat.");
-
writer.WriteString("className", cat.ClassName);
if (cat.ColorOption.IsSet)
writer.WriteString("color", cat.Color);
if (cat.DeclawedOption.IsSet)
- writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ if (cat.DeclawedOption.Value != null)
+ writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ else
+ writer.WriteNull("declawed");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
index 936d8dc8b225..f40778b17c24 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
@@ -152,9 +152,6 @@ public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (!name.IsSet)
throw new ArgumentException("Property is required for class Category.", nameof(name));
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category.");
-
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category.");
@@ -189,7 +186,10 @@ public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerial
throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
if (category.IdOption.IsSet)
- writer.WriteNumber("id", category.IdOption.Value!.Value);
+ if (category.IdOption.Value != null)
+ writer.WriteNumber("id", category.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
writer.WriteString("name", category.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
index c37ba2ec211e..cc30d23ad45c 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -189,9 +189,6 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
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.");
@@ -222,9 +219,6 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
{
- if (childCat.NameOption.IsSet && childCat.Name == null)
- throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat.");
-
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
index 5a199576ee29..77511092b81d 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -136,9 +136,6 @@ public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel.");
-
return new ClassModel(varClass);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
{
- if (classModel.ClassOption.IsSet && classModel.Class == null)
- throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel.");
-
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index d908fed19a3a..363b5623e0b3 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -142,9 +142,6 @@ public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null)
- throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass.");
-
return new DateOnlyClass(dateOnlyProperty);
}
@@ -173,7 +170,10 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
- writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ if (dateOnlyClass.DateOnlyPropertyOption.Value != null)
+ writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ else
+ writer.WriteNull("dateOnlyProperty");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index 68e0836b632f..40d33cc49b93 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -136,9 +136,6 @@ public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject.");
-
return new DeprecatedObject(name);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj
///
public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null)
- throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject.");
-
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
index 05eb0781cfe7..3336440935fa 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
@@ -135,12 +135,6 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog.");
- if (breed.IsSet && breed.Value == null)
- throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog.");
-
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog.");
-
return new Dog(breed, color);
}
@@ -168,12 +162,6 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
{
- if (dog.BreedOption.IsSet && dog.Breed == null)
- throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog.");
-
- if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
-
writer.WriteString("className", dog.ClassName);
if (dog.BreedOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
index 1668434a783f..36cda7a41304 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
@@ -196,12 +196,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (mainShape.IsSet && mainShape.Value == null)
- throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing.");
-
- if (shapes.IsSet && shapes.Value == null)
- throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing.");
-
return new Drawing(mainShape, nullableShape, shapeOrNull, shapes);
}
@@ -229,12 +223,6 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
{
- if (drawing.MainShapeOption.IsSet && drawing.MainShape == null)
- throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing.");
-
- if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
-
if (drawing.MainShapeOption.IsSet)
{
writer.WritePropertyName("mainShape");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
index 9a6f097e92c2..0dbae86d74c1 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -290,12 +290,6 @@ public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (arrayEnum.IsSet && arrayEnum.Value == null)
- throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays.");
-
- if (justSymbol.IsSet && justSymbol.Value == null)
- throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays.");
-
return new EnumArrays(arrayEnum, justSymbol);
}
@@ -323,9 +317,6 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
{
- if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null)
- throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays.");
-
if (enumArrays.ArrayEnumOption.IsSet)
{
writer.WritePropertyName("array_enum");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
index ea7a5bd26988..a6ad620905e3 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -791,27 +791,6 @@ public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (enumStringRequired.IsSet && enumStringRequired.Value == null)
throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest.");
- if (enumInteger.IsSet && enumInteger.Value == null)
- throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest.");
-
- if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest.");
-
- if (enumNumber.IsSet && enumNumber.Value == null)
- throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest.");
-
- if (enumString.IsSet && enumString.Value == null)
- throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest.");
-
- if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest.");
-
- if (outerEnumInteger.IsSet && outerEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest.");
-
- if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest.");
-
return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue);
}
@@ -842,13 +821,22 @@ public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerial
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
- writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ if (enumTest.EnumIntegerOption.Value != null)
+ writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer");
if (enumTest.EnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ if (enumTest.EnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer_only");
if (enumTest.EnumNumberOption.IsSet)
- writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ if (enumTest.EnumNumberOption.Value != null)
+ writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ else
+ writer.WriteNull("enum_number");
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
writer.WriteString("enum_string", enumStringRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
index dab2e4e27b36..bb17ff53d25e 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
@@ -137,9 +137,6 @@ public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (sourceURI.IsSet && sourceURI.Value == null)
- throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File.");
-
return new File(sourceURI);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
{
- if (file.SourceURIOption.IsSet && file.SourceURI == null)
- throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File.");
-
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 971a81e9c8c4..1b428026dab9 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -156,12 +156,6 @@ public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (file.IsSet && file.Value == null)
- throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass.");
-
- if (files.IsSet && files.Value == null)
- throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass.");
-
return new FileSchemaTestClass(file, files);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema
///
public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass.");
-
- if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
-
if (fileSchemaTestClass.FileOption.IsSet)
{
writer.WritePropertyName("file");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
index b8128f4c3e45..1649f2dcca78 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
@@ -136,9 +136,6 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
-
return new Foo(bar);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
- if (foo.BarOption.IsSet && foo.Bar == null)
- throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");
-
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index f4e54444c7ee..4b315c651541 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -136,9 +136,6 @@ public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Ty
}
}
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse.");
-
return new FooGetDefaultResponse(varString);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe
///
public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null)
- throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse.");
-
if (fooGetDefaultResponse.StringOption.IsSet)
{
writer.WritePropertyName("string");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
index 9e4b3c23fe8a..81285ddae396 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -847,75 +847,6 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (stringFormattedAsDecimalRequired.IsSet && stringFormattedAsDecimalRequired.Value == null)
throw new ArgumentNullException(nameof(stringFormattedAsDecimalRequired), "Property is not nullable for class FormatTest.");
- if (binary.IsSet && binary.Value == null)
- throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest.");
-
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest.");
-
- if (varDecimal.IsSet && varDecimal.Value == null)
- throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest.");
-
- if (varDouble.IsSet && varDouble.Value == null)
- throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName2.IsSet && duplicatePropertyName2.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName2), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName.IsSet && duplicatePropertyName.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName), "Property is not nullable for class FormatTest.");
-
- if (varFloat.IsSet && varFloat.Value == null)
- throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest.");
-
- if (int32.IsSet && int32.Value == null)
- throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest.");
-
- if (int32Range.IsSet && int32Range.Value == null)
- throw new ArgumentNullException(nameof(int32Range), "Property is not nullable for class FormatTest.");
-
- if (int64.IsSet && int64.Value == null)
- throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest.");
-
- if (int64Negative.IsSet && int64Negative.Value == null)
- throw new ArgumentNullException(nameof(int64Negative), "Property is not nullable for class FormatTest.");
-
- if (int64NegativeExclusive.IsSet && int64NegativeExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64NegativeExclusive), "Property is not nullable for class FormatTest.");
-
- if (int64Positive.IsSet && int64Positive.Value == null)
- throw new ArgumentNullException(nameof(int64Positive), "Property is not nullable for class FormatTest.");
-
- if (int64PositiveExclusive.IsSet && int64PositiveExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64PositiveExclusive), "Property is not nullable for class FormatTest.");
-
- if (integer.IsSet && integer.Value == null)
- throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest.");
-
- if (patternWithBackslash.IsSet && patternWithBackslash.Value == null)
- throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigits.IsSet && patternWithDigits.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest.");
-
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest.");
-
- if (stringFormattedAsDecimal.IsSet && stringFormattedAsDecimal.Value == null)
- throw new ArgumentNullException(nameof(stringFormattedAsDecimal), "Property is not nullable for class FormatTest.");
-
- if (unsignedInteger.IsSet && unsignedInteger.Value == null)
- throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest.");
-
- if (unsignedLong.IsSet && unsignedLong.Value == null)
- throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
-
return new FormatTest(varByte.Value!, date.Value!.Value!, number.Value!.Value!, password.Value!, stringFormattedAsDecimalRequired.Value!.Value!, binary, dateTime, varDecimal, varDouble, duplicatePropertyName2, duplicatePropertyName, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, stringFormattedAsDecimal, unsignedInteger, unsignedLong, uuid);
}
@@ -949,27 +880,6 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
if (formatTest.Password == null)
throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
-
- if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
-
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
@@ -986,7 +896,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions);
}
if (formatTest.DateTimeOption.IsSet)
- writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (formatTest.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (formatTest.DecimalOption.IsSet)
{
@@ -994,7 +907,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions);
}
if (formatTest.DoubleOption.IsSet)
- writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ if (formatTest.DoubleOption.Value != null)
+ writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ else
+ writer.WriteNull("double");
if (formatTest.DuplicatePropertyName2Option.IsSet)
writer.WriteString("duplicate_property_name", formatTest.DuplicatePropertyName2);
@@ -1003,31 +919,58 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("@duplicate_property_name", formatTest.DuplicatePropertyName);
if (formatTest.FloatOption.IsSet)
- writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ if (formatTest.FloatOption.Value != null)
+ writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ else
+ writer.WriteNull("float");
if (formatTest.Int32Option.IsSet)
- writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ if (formatTest.Int32Option.Value != null)
+ writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ else
+ writer.WriteNull("int32");
if (formatTest.Int32RangeOption.IsSet)
- writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ if (formatTest.Int32RangeOption.Value != null)
+ writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ else
+ writer.WriteNull("int32Range");
if (formatTest.Int64Option.IsSet)
- writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ if (formatTest.Int64Option.Value != null)
+ writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ else
+ writer.WriteNull("int64");
if (formatTest.Int64NegativeOption.IsSet)
- writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ if (formatTest.Int64NegativeOption.Value != null)
+ writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ else
+ writer.WriteNull("int64Negative");
if (formatTest.Int64NegativeExclusiveOption.IsSet)
- writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ if (formatTest.Int64NegativeExclusiveOption.Value != null)
+ writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64NegativeExclusive");
if (formatTest.Int64PositiveOption.IsSet)
- writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ if (formatTest.Int64PositiveOption.Value != null)
+ writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64Positive");
if (formatTest.Int64PositiveExclusiveOption.IsSet)
- writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ if (formatTest.Int64PositiveExclusiveOption.Value != null)
+ writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64PositiveExclusive");
if (formatTest.IntegerOption.IsSet)
- writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ if (formatTest.IntegerOption.Value != null)
+ writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ else
+ writer.WriteNull("integer");
if (formatTest.PatternWithBackslashOption.IsSet)
writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash);
@@ -1042,16 +985,28 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("string", formatTest.String);
if (formatTest.StringFormattedAsDecimalOption.IsSet)
- writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ if (formatTest.StringFormattedAsDecimalOption.Value != null)
+ writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ else
+ writer.WriteNull("string_formatted_as_decimal");
if (formatTest.UnsignedIntegerOption.IsSet)
- writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ if (formatTest.UnsignedIntegerOption.Value != null)
+ writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_integer");
if (formatTest.UnsignedLongOption.IsSet)
- writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ if (formatTest.UnsignedLongOption.Value != null)
+ writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_long");
if (formatTest.UuidOption.IsSet)
- writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ if (formatTest.UuidOption.Value != null)
+ writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
index eb12679ed27d..04d8d8c83466 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
@@ -174,9 +174,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -210,9 +207,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
index d751e8154524..5b8b0531a47a 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -178,9 +178,6 @@ public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -227,9 +224,6 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (gmFruit.ColorOption.IsSet && gmFruit.Color == null)
- throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit.");
-
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index 50826dd0da5d..0c383b3b1776 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -197,12 +197,6 @@ public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typ
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly.");
-
- if (foo.IsSet && foo.Value == null)
- throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly.");
-
return new HasOnlyReadOnly(bar, foo);
}
@@ -230,12 +224,6 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl
///
public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly.");
-
- if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
-
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
index ddf0d615fd3c..774eddc243a8 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
@@ -136,9 +136,6 @@ public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (var123List.IsSet && var123List.Value == null)
- throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List.");
-
return new List(var123List);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
{
- if (list.Var123ListOption.IsSet && list.Var123List == null)
- throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List.");
-
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 5993dd82adc8..3525a34b369b 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -156,12 +156,6 @@ public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (escapedLiteralString.IsSet && escapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
- if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
return new LiteralStringClass(escapedLiteralString, unescapedLiteralString);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri
///
public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass.");
-
- if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
-
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
index 06668cf78934..0b68a78dfbd5 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
@@ -262,18 +262,6 @@ public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (directMap.IsSet && directMap.Value == null)
- throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest.");
-
- if (indirectMap.IsSet && indirectMap.Value == null)
- throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest.");
-
- if (mapMapOfString.IsSet && mapMapOfString.Value == null)
- throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest.");
-
- if (mapOfEnumString.IsSet && mapOfEnumString.Value == null)
- throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest.");
-
return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString);
}
@@ -301,18 +289,6 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest.");
-
- if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
-
- if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
-
- if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
-
if (mapTest.DirectMapOption.IsSet)
{
writer.WritePropertyName("direct_map");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 266cbf7f9d2e..15d32a530899 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -136,9 +136,6 @@ public override MixedAnyOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf.");
-
return new MixedAnyOf(content);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null)
- throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf.");
-
if (mixedAnyOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
index 4d5b2c6d94cf..6be715c794d8 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -136,9 +136,6 @@ public override MixedOneOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf.");
-
return new MixedOneOf(content);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null)
- throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf.");
-
if (mixedOneOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 968a64762901..ce2e08e1e124 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -208,18 +208,6 @@ public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonRea
}
}
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (map.IsSet && map.Value == null)
- throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuidWithPattern.IsSet && uuidWithPattern.Value == null)
- throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern);
}
@@ -247,11 +235,11 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
-
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
- writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet)
{
@@ -259,10 +247,16 @@ public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalP
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions);
}
if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet)
- writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value != null)
+ writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet)
- writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value != null)
+ writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ else
+ writer.WriteNull("uuid_with_pattern");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
index 6b56e6017b15..7cfbb5a22316 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -136,9 +136,6 @@ public override MixedSubId Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId.");
-
return new MixedSubId(id);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null)
- throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId.");
-
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
index 76bffb1856bc..7186223e67b6 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -156,12 +156,6 @@ public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response.");
-
return new Model200Response(varClass, name);
}
@@ -189,14 +183,14 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo
///
public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
{
- if (model200Response.ClassOption.IsSet && model200Response.Class == null)
- throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response.");
-
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
if (model200Response.NameOption.IsSet)
- writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ if (model200Response.NameOption.Value != null)
+ writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ else
+ writer.WriteNull("name");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
index 7a982b8104d3..eeb350f4964f 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -136,9 +136,6 @@ public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (varClient.IsSet && varClient.Value == null)
- throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient.");
-
return new ModelClient(varClient);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
{
- if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null)
- throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient.");
-
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
index 100ccfa20e5b..86e07bbbbc4c 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
@@ -236,15 +236,6 @@ public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (varName.IsSet && varName.Value == null)
throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name.");
- if (property.IsSet && property.Value == null)
- throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name.");
-
- if (snakeCase.IsSet && snakeCase.Value == null)
- throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name.");
-
- if (var123Number.IsSet && var123Number.Value == null)
- throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name.");
-
return new Name(varName.Value!.Value!, property, snakeCase, var123Number);
}
@@ -272,19 +263,22 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
{
- if (name.PropertyOption.IsSet && name.Property == null)
- throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name.");
-
writer.WriteNumber("name", name.VarName);
if (name.PropertyOption.IsSet)
writer.WriteString("property", name.Property);
if (name.SnakeCaseOption.IsSet)
- writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ if (name.SnakeCaseOption.Value != null)
+ writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ else
+ writer.WriteNull("snake_case");
if (name.Var123NumberOption.IsSet)
- writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ if (name.Var123NumberOption.Value != null)
+ writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ else
+ writer.WriteNull("123Number");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
index db7eaa8f675c..f7ff8f69bb9e 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -366,12 +366,6 @@ public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass.");
-
- if (objectItemsNullable.IsSet && objectItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass.");
-
return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp);
}
@@ -399,12 +393,6 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J
///
public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass.");
-
- if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
-
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
index f7ae912c05e6..b315d41bb949 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -136,9 +136,6 @@ public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (justNumber.IsSet && justNumber.Value == null)
- throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly.");
-
return new NumberOnly(justNumber);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (numberOnly.JustNumberOption.IsSet)
- writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ if (numberOnly.JustNumberOption.Value != null)
+ writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ else
+ writer.WriteNull("JustNumber");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index fa4f88b3ecdd..1317bd91560c 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -199,18 +199,6 @@ public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReade
}
}
- if (bars.IsSet && bars.Value == null)
- throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (deprecatedRef.IsSet && deprecatedRef.Value == null)
- throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid);
}
@@ -238,15 +226,6 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj
///
public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
{
- if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
-
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
writer.WritePropertyName("bars");
@@ -258,7 +237,10 @@ public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields ob
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions);
}
if (objectWithDeprecatedFields.IdOption.IsSet)
- writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ if (objectWithDeprecatedFields.IdOption.Value != null)
+ writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (objectWithDeprecatedFields.UuidOption.IsSet)
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
index c4c43309bec1..bf0237990786 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
@@ -326,24 +326,6 @@ public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (complete.IsSet && complete.Value == null)
- throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order.");
-
- if (petId.IsSet && petId.Value == null)
- throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order.");
-
- if (quantity.IsSet && quantity.Value == null)
- throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order.");
-
- if (shipDate.IsSet && shipDate.Value == null)
- throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order.");
-
return new Order(complete, id, petId, quantity, shipDate, status);
}
@@ -372,19 +354,34 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
if (order.CompleteOption.IsSet)
- writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ if (order.CompleteOption.Value != null)
+ writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ else
+ writer.WriteNull("complete");
if (order.IdOption.IsSet)
- writer.WriteNumber("id", order.IdOption.Value!.Value);
+ if (order.IdOption.Value != null)
+ writer.WriteNumber("id", order.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (order.PetIdOption.IsSet)
- writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ if (order.PetIdOption.Value != null)
+ writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ else
+ writer.WriteNull("petId");
if (order.QuantityOption.IsSet)
- writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ if (order.QuantityOption.Value != null)
+ writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ else
+ writer.WriteNull("quantity");
if (order.ShipDateOption.IsSet)
- writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ if (order.ShipDateOption.Value != null)
+ writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ else
+ writer.WriteNull("shipDate");
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
index 4428479e0485..f9c6a1474bae 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -176,15 +176,6 @@ public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (myBoolean.IsSet && myBoolean.Value == null)
- throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite.");
-
- if (myNumber.IsSet && myNumber.Value == null)
- throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite.");
-
- if (myString.IsSet && myString.Value == null)
- throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite.");
-
return new OuterComposite(myBoolean, myNumber, myString);
}
@@ -212,14 +203,17 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
- if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
-
if (outerComposite.MyBooleanOption.IsSet)
- writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ if (outerComposite.MyBooleanOption.Value != null)
+ writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ else
+ writer.WriteNull("my_boolean");
if (outerComposite.MyNumberOption.IsSet)
- writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ if (outerComposite.MyNumberOption.Value != null)
+ writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ else
+ writer.WriteNull("my_number");
if (outerComposite.MyStringOption.IsSet)
writer.WriteString("my_string", outerComposite.MyString);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
index 56b981a0e2ad..9557747c46dc 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
@@ -319,18 +319,6 @@ public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (photoUrls.IsSet && photoUrls.Value == null)
throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet.");
- if (category.IsSet && category.Value == null)
- throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet.");
-
- if (tags.IsSet && tags.Value == null)
- throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet.");
-
return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags);
}
@@ -364,12 +352,6 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
if (pet.PhotoUrls == null)
throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
-
- if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
-
writer.WriteString("name", pet.Name);
writer.WritePropertyName("photoUrls");
@@ -380,7 +362,10 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions);
}
if (pet.IdOption.IsSet)
- writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ if (pet.IdOption.Value != null)
+ writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index a48fcb21dbef..17016304c4dd 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -194,12 +194,6 @@ public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst.");
-
- if (baz.IsSet && baz.Value == null)
- throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst.");
-
return new ReadOnlyFirst(bar, baz);
}
@@ -227,12 +221,6 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J
///
public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
{
- if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst.");
-
- if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
-
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
index 0c7dc7eab56f..ce661233c93b 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2079,39 +2079,6 @@ public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null)
throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
- if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass.");
-
- if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass.");
-
return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!);
}
@@ -2145,12 +2112,6 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
if (requiredClass.RequiredNotnullableStringProp == null)
throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
- if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
-
- if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
-
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
writer.WritePropertyName("required_notnullable_array_of_string");
@@ -2175,10 +2136,16 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp);
if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet)
- writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ if (requiredClass.NotRequiredNotnullableDatePropOption.Value != null)
+ writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ else
+ writer.WriteNull("not_required_notnullable_date_prop");
if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet)
- writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.Value != null)
+ writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ else
+ writer.WriteNull("not_required_notnullableinteger_prop");
if (requiredClass.NotRequiredNullableDatePropOption.IsSet)
if (requiredClass.NotRequiredNullableDatePropOption.Value != null)
@@ -2198,16 +2165,28 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions);
}
if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet)
- writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.Value != null)
+ writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_boolean_prop");
if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet)
- writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.Value != null)
+ writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ else
+ writer.WriteNull("notrequired_notnullable_datetime_prop");
if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer");
if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer_only");
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
@@ -2220,7 +2199,10 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp);
if (requiredClass.NotrequiredNotnullableUuidOption.IsSet)
- writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableUuidOption.Value != null)
+ writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_uuid");
if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet)
if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
index 6119748b2992..0c8e9be329f9 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
@@ -179,15 +179,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result.");
-
return new Result(code, data, uuid);
}
@@ -215,15 +206,6 @@ public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions)
{
- if (result.CodeOption.IsSet && result.Code == null)
- throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result.");
-
- if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
-
- if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
-
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
index 6276a3a8c8ae..752ea2da319e 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
@@ -191,12 +191,6 @@ public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (varLock.IsSet && varLock.Value == null)
throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return.");
- if (varReturn.IsSet && varReturn.Value == null)
- throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return.");
-
- if (varUnsafe.IsSet && varUnsafe.Value == null)
- throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return.");
-
return new Return(varLock.Value!, varAbstract.Value!, varReturn, varUnsafe);
}
@@ -227,9 +221,6 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
if (varReturn.Lock == null)
throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
- if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
-
writer.WriteString("lock", varReturn.Lock);
if (varReturn.Abstract != null)
@@ -238,7 +229,10 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
writer.WriteNull("abstract");
if (varReturn.VarReturnOption.IsSet)
- writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ if (varReturn.VarReturnOption.Value != null)
+ writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ else
+ writer.WriteNull("return");
if (varReturn.UnsafeOption.IsSet)
writer.WriteString("unsafe", varReturn.Unsafe);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index 245ea1053e5d..3219fdf99dde 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -156,12 +156,6 @@ public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (role.IsSet && role.Value == null)
- throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash.");
-
- if (roleUuid.IsSet && roleUuid.Value == null)
- throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash.");
-
return new RolesReportsHash(role, roleUuid);
}
@@ -189,16 +183,16 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null)
- throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash.");
-
if (rolesReportsHash.RoleOption.IsSet)
{
writer.WritePropertyName("role");
JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions);
}
if (rolesReportsHash.RoleUuidOption.IsSet)
- writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ if (rolesReportsHash.RoleUuidOption.Value != null)
+ writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ else
+ writer.WriteNull("role_uuid");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 684ca8e8b515..45e278a334ff 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -136,9 +136,6 @@ public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Typ
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole.");
-
return new RolesReportsHashRole(name);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null)
- throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole.");
-
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 1fce10cd7823..bd2b77eb5ce9 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -156,12 +156,6 @@ public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varSpecialModelName.IsSet && varSpecialModelName.Value == null)
- throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName.");
-
- if (specialPropertyName.IsSet && specialPropertyName.Value == null)
- throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName.");
-
return new SpecialModelName(varSpecialModelName, specialPropertyName);
}
@@ -189,14 +183,14 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN
///
public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
{
- if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null)
- throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName.");
-
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
if (specialModelName.SpecialPropertyNameOption.IsSet)
- writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ if (specialModelName.SpecialPropertyNameOption.Value != null)
+ writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ else
+ writer.WriteNull("$special[property.name]");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
index a6c404c940b8..089fc767f734 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
@@ -156,12 +156,6 @@ public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag.");
-
return new Tag(id, name);
}
@@ -189,11 +183,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
- if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
-
if (tag.IdOption.IsSet)
- writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ if (tag.IdOption.Value != null)
+ writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (tag.NameOption.IsSet)
writer.WriteString("name", tag.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index f1a1940574ee..5a0353bce33d 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -136,9 +136,6 @@ public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8Jso
}
}
- if (value.IsSet && value.Value == null)
- throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList.");
-
return new TestCollectionEndingWithWordList(value);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList.");
-
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index 5cbf9d28f57e..b86b7b610c6e 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -136,9 +136,6 @@ public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader u
}
}
- if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject.");
-
return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject.");
-
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
writer.WritePropertyName("TestCollectionEndingWithWordList");
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index 102413449b18..e626f9975ce5 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -136,9 +136,6 @@ public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonR
}
}
- if (someProperty.IsSet && someProperty.Value == null)
- throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest.");
-
return new TestInlineFreeformAdditionalPropertiesRequest(someProperty);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
{
- if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null)
- throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest.");
-
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
index e7829b5974ee..dfe6d8e7a887 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
@@ -180,15 +180,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult.");
-
return new TestResult(code, data, uuid);
}
@@ -216,12 +207,6 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
- if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
-
- if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
-
if (testResult.CodeOption.IsSet)
{
var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
index d02f765752fd..af12ad03e1bc 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
@@ -361,33 +361,6 @@ public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (email.IsSet && email.Value == null)
- throw new ArgumentNullException(nameof(email), "Property is not nullable for class User.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class User.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User.");
-
- if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null)
- throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User.");
-
- if (password.IsSet && password.Value == null)
- throw new ArgumentNullException(nameof(password), "Property is not nullable for class User.");
-
- if (phone.IsSet && phone.Value == null)
- throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User.");
-
- if (userStatus.IsSet && userStatus.Value == null)
- throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User.");
-
- if (username.IsSet && username.Value == null)
- throw new ArgumentNullException(nameof(username), "Property is not nullable for class User.");
-
return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username);
}
@@ -415,27 +388,6 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
{
- if (user.EmailOption.IsSet && user.Email == null)
- throw new ArgumentNullException(nameof(user.Email), "Property is required for class User.");
-
- if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
-
- if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
-
- if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
-
- if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
-
- if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
-
- if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
-
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
{
@@ -459,7 +411,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("firstName", user.FirstName);
if (user.IdOption.IsSet)
- writer.WriteNumber("id", user.IdOption.Value!.Value);
+ if (user.IdOption.Value != null)
+ writer.WriteNumber("id", user.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (user.LastNameOption.IsSet)
writer.WriteString("lastName", user.LastName);
@@ -484,7 +439,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("phone", user.Phone);
if (user.UserStatusOption.IsSet)
- writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ if (user.UserStatusOption.Value != null)
+ writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ else
+ writer.WriteNull("userStatus");
if (user.UsernameOption.IsSet)
writer.WriteString("username", user.Username);
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
index 3d5ad4a7d676..07d268952b5f 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
@@ -175,12 +175,6 @@ public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale.");
- if (hasBaleen.IsSet && hasBaleen.Value == null)
- throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale.");
-
- if (hasTeeth.IsSet && hasTeeth.Value == null)
- throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale.");
-
return new Whale(className.Value!, hasBaleen, hasTeeth);
}
@@ -214,10 +208,16 @@ public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOp
writer.WriteString("className", whale.ClassName);
if (whale.HasBaleenOption.IsSet)
- writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ if (whale.HasBaleenOption.Value != null)
+ writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ else
+ writer.WriteNull("hasBaleen");
if (whale.HasTeethOption.IsSet)
- writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ if (whale.HasTeethOption.Value != null)
+ writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ else
+ writer.WriteNull("hasTeeth");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
index 4ca12a36d096..716132325475 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
@@ -237,9 +237,6 @@ public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra.");
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra.");
-
return new Zebra(className.Value!, type);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index dfb395124397..59474730b6af 100644
--- a/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -204,9 +204,6 @@ public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null)
- throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass.");
-
return new ZeroBasedEnumClass(zeroBasedEnum);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs
index dd3528fa42a4..0826aac5f1a9 100644
--- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -136,9 +136,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs
index 170ad4b54dac..1cf95d5690f7 100644
--- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
index 056f2c03af8d..e1ad75e01636 100644
--- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -202,9 +202,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -241,9 +238,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Orange.cs b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Orange.cs
index eaa0165ba6c1..05777f379c18 100644
--- a/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Orange.cs
+++ b/samples/client/petstore/csharp/generichost/net8/OneOf/src/Org.OpenAPITools/Model/Orange.cs
@@ -136,9 +136,6 @@ public override Orange Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class Orange.");
-
return new Orange(sweet);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
if (orange.SweetOption.IsSet)
- writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
+ if (orange.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
index 65645b2e4829..e68030d8dfbe 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
@@ -137,9 +137,6 @@ public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
}
}
- if (activityOutputs.IsSet && activityOutputs.Value == null)
- throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity.");
-
return new Activity(activityOutputs);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
{
- if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null)
- throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity.");
-
if (activity.ActivityOutputsOption.IsSet)
{
writer.WritePropertyName("activity_outputs");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 728bbb0c349e..455cb9784010 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -157,12 +157,6 @@ public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8
}
}
- if (prop1.IsSet && prop1.Value == null)
- throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
- if (prop2.IsSet && prop2.Value == null)
- throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
return new ActivityOutputElementRepresentation(prop1, prop2);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent
///
public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
{
- if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation.");
-
- if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
-
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 9fa35476f70c..5d2b8f501bc5 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -278,27 +278,6 @@ public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader
}
}
- if (emptyMap.IsSet && emptyMap.Value == null)
- throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapProperty.IsSet && mapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass.");
-
return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString);
}
@@ -326,27 +305,6 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi
///
public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
-
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
index 37a0519bbd6b..ed53b38d189a 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
@@ -173,9 +173,6 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
-
return new Animal(color);
}
@@ -213,9 +210,6 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
{
- if (animal.ColorOption.IsSet && animal.Color == null)
- throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal.");
-
writer.WriteString("className", animal.ClassName);
if (animal.ColorOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
index bf92565f9a2e..ca3b2c1fdfd9 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -177,15 +177,6 @@ public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse.");
-
- if (message.IsSet && message.Value == null)
- throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse.");
-
return new ApiResponse(code, message, type);
}
@@ -213,14 +204,11 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
-
- if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
-
if (apiResponse.CodeOption.IsSet)
- writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ if (apiResponse.CodeOption.Value != null)
+ writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ else
+ writer.WriteNull("code");
if (apiResponse.MessageOption.IsSet)
writer.WriteString("message", apiResponse.Message);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
index 3dab90bbeb36..e1c0f65ea706 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
@@ -207,15 +207,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (colorCode.IsSet && colorCode.Value == null)
- throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple.");
-
- if (cultivar.IsSet && cultivar.Value == null)
- throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple.");
-
- if (origin.IsSet && origin.Value == null)
- throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple.");
-
return new Apple(colorCode, cultivar, origin);
}
@@ -243,15 +234,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.ColorCodeOption.IsSet && apple.ColorCode == null)
- throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple.");
-
- if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
-
- if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
-
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
index cbb5ea8f0849..c8344376a888 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -149,9 +149,6 @@ public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (cultivar.IsSet && cultivar.Value == null)
throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq.");
- if (mealy.IsSet && mealy.Value == null)
- throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq.");
-
return new AppleReq(cultivar.Value!, mealy);
}
@@ -185,7 +182,10 @@ public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerial
writer.WriteString("cultivar", appleReq.Cultivar);
if (appleReq.MealyOption.IsSet)
- writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ if (appleReq.MealyOption.Value != null)
+ writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ else
+ writer.WriteNull("mealy");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index cd3309a5900e..31072802633a 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -137,9 +137,6 @@ public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader,
}
}
- if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly.");
-
return new ArrayOfArrayOfNumberOnly(arrayArrayNumber);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly.");
-
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 90b6e4a8bd14..c605df6473f5 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -137,9 +137,6 @@ public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (arrayNumber.IsSet && arrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly.");
-
return new ArrayOfNumberOnly(arrayNumber);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly.");
-
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
index 6be410aad46e..33316827318d 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -177,15 +177,6 @@ public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
}
}
- if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest.");
-
- if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest.");
-
- if (arrayOfString.IsSet && arrayOfString.Value == null)
- throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest.");
-
return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString);
}
@@ -213,15 +204,6 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
-
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
writer.WritePropertyName("array_array_of_integer");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
index 1352e54c4091..74829deb5fb1 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
@@ -137,9 +137,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (lengthCm.IsSet && lengthCm.Value == null)
- throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana.");
-
return new Banana(lengthCm);
}
@@ -168,7 +165,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.LengthCmOption.IsSet)
- writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ if (banana.LengthCmOption.Value != null)
+ writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ else
+ writer.WriteNull("lengthCm");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
index 584505890fdc..0c9228dac974 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -149,9 +149,6 @@ public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
if (lengthCm.IsSet && lengthCm.Value == null)
throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq.");
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq.");
-
return new BananaReq(lengthCm.Value!.Value!, sweet);
}
@@ -182,7 +179,10 @@ public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeri
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
- writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ if (bananaReq.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
index e36a343dc5e2..7507fbf15047 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -238,24 +238,6 @@ public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (aTTNAME.IsSet && aTTNAME.Value == null)
- throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization.");
-
- if (capitalCamel.IsSet && capitalCamel.Value == null)
- throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization.");
-
- if (capitalSnake.IsSet && capitalSnake.Value == null)
- throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization.");
-
- if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null)
- throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization.");
-
- if (smallCamel.IsSet && smallCamel.Value == null)
- throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization.");
-
- if (smallSnake.IsSet && smallSnake.Value == null)
- throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization.");
-
return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake);
}
@@ -283,24 +265,6 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization,
///
public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
{
- if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null)
- throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
-
- if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
-
- if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
-
- if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
-
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
index 00b32d995aa3..2451fa64efcb 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
@@ -136,12 +136,6 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat.");
-
- if (declawed.IsSet && declawed.Value == null)
- throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat.");
-
return new Cat(color, declawed);
}
@@ -169,16 +163,16 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
{
- if (cat.ColorOption.IsSet && cat.Color == null)
- throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat.");
-
writer.WriteString("className", cat.ClassName);
if (cat.ColorOption.IsSet)
writer.WriteString("color", cat.Color);
if (cat.DeclawedOption.IsSet)
- writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ if (cat.DeclawedOption.Value != null)
+ writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ else
+ writer.WriteNull("declawed");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
index 0369f8f37e97..40e17252a708 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
@@ -153,9 +153,6 @@ public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (!name.IsSet)
throw new ArgumentException("Property is required for class Category.", nameof(name));
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category.");
-
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category.");
@@ -190,7 +187,10 @@ public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerial
throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
if (category.IdOption.IsSet)
- writer.WriteNumber("id", category.IdOption.Value!.Value);
+ if (category.IdOption.Value != null)
+ writer.WriteNumber("id", category.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
writer.WriteString("name", category.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
index 4131c59373af..219f38158e71 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -190,9 +190,6 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
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.");
@@ -223,9 +220,6 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
{
- if (childCat.NameOption.IsSet && childCat.Name == null)
- throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat.");
-
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
index e38fad89dbad..b29dc2232486 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -137,9 +137,6 @@ public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel.");
-
return new ClassModel(varClass);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
{
- if (classModel.ClassOption.IsSet && classModel.Class == null)
- throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel.");
-
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 8981331c9e19..cadefcdc9294 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -143,9 +143,6 @@ public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null)
- throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass.");
-
return new DateOnlyClass(dateOnlyProperty);
}
@@ -174,7 +171,10 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
- writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ if (dateOnlyClass.DateOnlyPropertyOption.Value != null)
+ writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ else
+ writer.WriteNull("dateOnlyProperty");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index 0b8716d11ff4..209ad029521a 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -137,9 +137,6 @@ public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject.");
-
return new DeprecatedObject(name);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj
///
public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null)
- throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject.");
-
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
index 6129b69ce916..eebabaf3da26 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
@@ -136,12 +136,6 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog.");
- if (breed.IsSet && breed.Value == null)
- throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog.");
-
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog.");
-
return new Dog(breed, color);
}
@@ -169,12 +163,6 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
{
- if (dog.BreedOption.IsSet && dog.Breed == null)
- throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog.");
-
- if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
-
writer.WriteString("className", dog.ClassName);
if (dog.BreedOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
index b6400a09e802..1ca6b42dead8 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
@@ -197,12 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (mainShape.IsSet && mainShape.Value == null)
- throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing.");
-
- if (shapes.IsSet && shapes.Value == null)
- throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing.");
-
return new Drawing(mainShape, nullableShape, shapeOrNull, shapes);
}
@@ -230,12 +224,6 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
{
- if (drawing.MainShapeOption.IsSet && drawing.MainShape == null)
- throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing.");
-
- if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
-
if (drawing.MainShapeOption.IsSet)
{
writer.WritePropertyName("mainShape");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
index 5c9774abc417..5a0ae3fe8c07 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -291,12 +291,6 @@ public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (arrayEnum.IsSet && arrayEnum.Value == null)
- throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays.");
-
- if (justSymbol.IsSet && justSymbol.Value == null)
- throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays.");
-
return new EnumArrays(arrayEnum, justSymbol);
}
@@ -324,9 +318,6 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
{
- if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null)
- throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays.");
-
if (enumArrays.ArrayEnumOption.IsSet)
{
writer.WritePropertyName("array_enum");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
index 897a9bd24efe..4c672d70aaf8 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -792,27 +792,6 @@ public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (enumStringRequired.IsSet && enumStringRequired.Value == null)
throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest.");
- if (enumInteger.IsSet && enumInteger.Value == null)
- throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest.");
-
- if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest.");
-
- if (enumNumber.IsSet && enumNumber.Value == null)
- throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest.");
-
- if (enumString.IsSet && enumString.Value == null)
- throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest.");
-
- if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest.");
-
- if (outerEnumInteger.IsSet && outerEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest.");
-
- if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest.");
-
return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue);
}
@@ -843,13 +822,22 @@ public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerial
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
- writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ if (enumTest.EnumIntegerOption.Value != null)
+ writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer");
if (enumTest.EnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ if (enumTest.EnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer_only");
if (enumTest.EnumNumberOption.IsSet)
- writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ if (enumTest.EnumNumberOption.Value != null)
+ writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ else
+ writer.WriteNull("enum_number");
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
writer.WriteString("enum_string", enumStringRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
index bdc5c25e1329..074dc96d0a9f 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
@@ -138,9 +138,6 @@ public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (sourceURI.IsSet && sourceURI.Value == null)
- throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File.");
-
return new File(sourceURI);
}
@@ -168,9 +165,6 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
{
- if (file.SourceURIOption.IsSet && file.SourceURI == null)
- throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File.");
-
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index d7c977f2fe4f..f5681591bd7f 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -157,12 +157,6 @@ public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (file.IsSet && file.Value == null)
- throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass.");
-
- if (files.IsSet && files.Value == null)
- throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass.");
-
return new FileSchemaTestClass(file, files);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema
///
public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass.");
-
- if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
-
if (fileSchemaTestClass.FileOption.IsSet)
{
writer.WritePropertyName("file");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
index ac4aeb49df5c..d68007dd2828 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
@@ -137,9 +137,6 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
-
return new Foo(bar);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
- if (foo.BarOption.IsSet && foo.Bar == null)
- throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");
-
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 9f57f4d6318a..bc458b1bd4fe 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -137,9 +137,6 @@ public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Ty
}
}
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse.");
-
return new FooGetDefaultResponse(varString);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe
///
public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null)
- throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse.");
-
if (fooGetDefaultResponse.StringOption.IsSet)
{
writer.WritePropertyName("string");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
index 3daacf80952d..f00f123ade8b 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -848,75 +848,6 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (stringFormattedAsDecimalRequired.IsSet && stringFormattedAsDecimalRequired.Value == null)
throw new ArgumentNullException(nameof(stringFormattedAsDecimalRequired), "Property is not nullable for class FormatTest.");
- if (binary.IsSet && binary.Value == null)
- throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest.");
-
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest.");
-
- if (varDecimal.IsSet && varDecimal.Value == null)
- throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest.");
-
- if (varDouble.IsSet && varDouble.Value == null)
- throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName2.IsSet && duplicatePropertyName2.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName2), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName.IsSet && duplicatePropertyName.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName), "Property is not nullable for class FormatTest.");
-
- if (varFloat.IsSet && varFloat.Value == null)
- throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest.");
-
- if (int32.IsSet && int32.Value == null)
- throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest.");
-
- if (int32Range.IsSet && int32Range.Value == null)
- throw new ArgumentNullException(nameof(int32Range), "Property is not nullable for class FormatTest.");
-
- if (int64.IsSet && int64.Value == null)
- throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest.");
-
- if (int64Negative.IsSet && int64Negative.Value == null)
- throw new ArgumentNullException(nameof(int64Negative), "Property is not nullable for class FormatTest.");
-
- if (int64NegativeExclusive.IsSet && int64NegativeExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64NegativeExclusive), "Property is not nullable for class FormatTest.");
-
- if (int64Positive.IsSet && int64Positive.Value == null)
- throw new ArgumentNullException(nameof(int64Positive), "Property is not nullable for class FormatTest.");
-
- if (int64PositiveExclusive.IsSet && int64PositiveExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64PositiveExclusive), "Property is not nullable for class FormatTest.");
-
- if (integer.IsSet && integer.Value == null)
- throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest.");
-
- if (patternWithBackslash.IsSet && patternWithBackslash.Value == null)
- throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigits.IsSet && patternWithDigits.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest.");
-
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest.");
-
- if (stringFormattedAsDecimal.IsSet && stringFormattedAsDecimal.Value == null)
- throw new ArgumentNullException(nameof(stringFormattedAsDecimal), "Property is not nullable for class FormatTest.");
-
- if (unsignedInteger.IsSet && unsignedInteger.Value == null)
- throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest.");
-
- if (unsignedLong.IsSet && unsignedLong.Value == null)
- throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
-
return new FormatTest(varByte.Value!, date.Value!.Value!, number.Value!.Value!, password.Value!, stringFormattedAsDecimalRequired.Value!.Value!, binary, dateTime, varDecimal, varDouble, duplicatePropertyName2, duplicatePropertyName, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, stringFormattedAsDecimal, unsignedInteger, unsignedLong, uuid);
}
@@ -950,27 +881,6 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
if (formatTest.Password == null)
throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
-
- if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
-
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
@@ -987,7 +897,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions);
}
if (formatTest.DateTimeOption.IsSet)
- writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (formatTest.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (formatTest.DecimalOption.IsSet)
{
@@ -995,7 +908,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions);
}
if (formatTest.DoubleOption.IsSet)
- writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ if (formatTest.DoubleOption.Value != null)
+ writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ else
+ writer.WriteNull("double");
if (formatTest.DuplicatePropertyName2Option.IsSet)
writer.WriteString("duplicate_property_name", formatTest.DuplicatePropertyName2);
@@ -1004,31 +920,58 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("@duplicate_property_name", formatTest.DuplicatePropertyName);
if (formatTest.FloatOption.IsSet)
- writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ if (formatTest.FloatOption.Value != null)
+ writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ else
+ writer.WriteNull("float");
if (formatTest.Int32Option.IsSet)
- writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ if (formatTest.Int32Option.Value != null)
+ writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ else
+ writer.WriteNull("int32");
if (formatTest.Int32RangeOption.IsSet)
- writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ if (formatTest.Int32RangeOption.Value != null)
+ writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ else
+ writer.WriteNull("int32Range");
if (formatTest.Int64Option.IsSet)
- writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ if (formatTest.Int64Option.Value != null)
+ writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ else
+ writer.WriteNull("int64");
if (formatTest.Int64NegativeOption.IsSet)
- writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ if (formatTest.Int64NegativeOption.Value != null)
+ writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ else
+ writer.WriteNull("int64Negative");
if (formatTest.Int64NegativeExclusiveOption.IsSet)
- writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ if (formatTest.Int64NegativeExclusiveOption.Value != null)
+ writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64NegativeExclusive");
if (formatTest.Int64PositiveOption.IsSet)
- writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ if (formatTest.Int64PositiveOption.Value != null)
+ writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64Positive");
if (formatTest.Int64PositiveExclusiveOption.IsSet)
- writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ if (formatTest.Int64PositiveExclusiveOption.Value != null)
+ writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64PositiveExclusive");
if (formatTest.IntegerOption.IsSet)
- writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ if (formatTest.IntegerOption.Value != null)
+ writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ else
+ writer.WriteNull("integer");
if (formatTest.PatternWithBackslashOption.IsSet)
writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash);
@@ -1043,16 +986,28 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("string", formatTest.String);
if (formatTest.StringFormattedAsDecimalOption.IsSet)
- writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ if (formatTest.StringFormattedAsDecimalOption.Value != null)
+ writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ else
+ writer.WriteNull("string_formatted_as_decimal");
if (formatTest.UnsignedIntegerOption.IsSet)
- writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ if (formatTest.UnsignedIntegerOption.Value != null)
+ writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_integer");
if (formatTest.UnsignedLongOption.IsSet)
- writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ if (formatTest.UnsignedLongOption.Value != null)
+ writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_long");
if (formatTest.UuidOption.IsSet)
- writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ if (formatTest.UuidOption.Value != null)
+ writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
index 6aa166222089..de97c93e546a 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
@@ -175,9 +175,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -211,9 +208,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
index 8b41879612ea..b13b4b826059 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -179,9 +179,6 @@ public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -228,9 +225,6 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (gmFruit.ColorOption.IsSet && gmFruit.Color == null)
- throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit.");
-
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index 0bf77a18dca2..680d39774424 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -198,12 +198,6 @@ public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typ
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly.");
-
- if (foo.IsSet && foo.Value == null)
- throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly.");
-
return new HasOnlyReadOnly(bar, foo);
}
@@ -231,12 +225,6 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl
///
public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly.");
-
- if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
-
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
index 024998ed763a..a15f8babfebd 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
@@ -137,9 +137,6 @@ public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (var123List.IsSet && var123List.Value == null)
- throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List.");
-
return new List(var123List);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
{
- if (list.Var123ListOption.IsSet && list.Var123List == null)
- throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List.");
-
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e54eebdaa1dc..bfefac8c977f 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -157,12 +157,6 @@ public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (escapedLiteralString.IsSet && escapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
- if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
return new LiteralStringClass(escapedLiteralString, unescapedLiteralString);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri
///
public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass.");
-
- if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
-
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
index 40dee3f15569..775fe4599442 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
@@ -263,18 +263,6 @@ public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (directMap.IsSet && directMap.Value == null)
- throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest.");
-
- if (indirectMap.IsSet && indirectMap.Value == null)
- throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest.");
-
- if (mapMapOfString.IsSet && mapMapOfString.Value == null)
- throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest.");
-
- if (mapOfEnumString.IsSet && mapOfEnumString.Value == null)
- throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest.");
-
return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString);
}
@@ -302,18 +290,6 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest.");
-
- if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
-
- if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
-
- if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
-
if (mapTest.DirectMapOption.IsSet)
{
writer.WritePropertyName("direct_map");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index cdac03c3bcf4..b7562da53ca1 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -137,9 +137,6 @@ public override MixedAnyOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf.");
-
return new MixedAnyOf(content);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null)
- throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf.");
-
if (mixedAnyOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
index e9f36662dd80..cf8a31520783 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -137,9 +137,6 @@ public override MixedOneOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf.");
-
return new MixedOneOf(content);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null)
- throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf.");
-
if (mixedOneOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3629d644571b..fcfbae83d506 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -209,18 +209,6 @@ public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonRea
}
}
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (map.IsSet && map.Value == null)
- throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuidWithPattern.IsSet && uuidWithPattern.Value == null)
- throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern);
}
@@ -248,11 +236,11 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
-
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
- writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet)
{
@@ -260,10 +248,16 @@ public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalP
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions);
}
if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet)
- writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value != null)
+ writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet)
- writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value != null)
+ writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ else
+ writer.WriteNull("uuid_with_pattern");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
index 696681a920f3..daae5ac2d835 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -137,9 +137,6 @@ public override MixedSubId Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId.");
-
return new MixedSubId(id);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null)
- throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId.");
-
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
index 4b3f421263d4..bf378de647bc 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -157,12 +157,6 @@ public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response.");
-
return new Model200Response(varClass, name);
}
@@ -190,14 +184,14 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo
///
public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
{
- if (model200Response.ClassOption.IsSet && model200Response.Class == null)
- throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response.");
-
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
if (model200Response.NameOption.IsSet)
- writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ if (model200Response.NameOption.Value != null)
+ writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ else
+ writer.WriteNull("name");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
index 49dcb68c571f..06d54d89c068 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -137,9 +137,6 @@ public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (varClient.IsSet && varClient.Value == null)
- throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient.");
-
return new ModelClient(varClient);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
{
- if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null)
- throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient.");
-
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
index 72938274943d..9536a8c463c1 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
@@ -237,15 +237,6 @@ public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (varName.IsSet && varName.Value == null)
throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name.");
- if (property.IsSet && property.Value == null)
- throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name.");
-
- if (snakeCase.IsSet && snakeCase.Value == null)
- throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name.");
-
- if (var123Number.IsSet && var123Number.Value == null)
- throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name.");
-
return new Name(varName.Value!.Value!, property, snakeCase, var123Number);
}
@@ -273,19 +264,22 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
{
- if (name.PropertyOption.IsSet && name.Property == null)
- throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name.");
-
writer.WriteNumber("name", name.VarName);
if (name.PropertyOption.IsSet)
writer.WriteString("property", name.Property);
if (name.SnakeCaseOption.IsSet)
- writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ if (name.SnakeCaseOption.Value != null)
+ writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ else
+ writer.WriteNull("snake_case");
if (name.Var123NumberOption.IsSet)
- writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ if (name.Var123NumberOption.Value != null)
+ writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ else
+ writer.WriteNull("123Number");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
index aa2baca6ee31..0158c4f696ad 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -367,12 +367,6 @@ public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass.");
-
- if (objectItemsNullable.IsSet && objectItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass.");
-
return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp);
}
@@ -400,12 +394,6 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J
///
public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass.");
-
- if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
-
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
index 3662647e6562..0604d74f5677 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -137,9 +137,6 @@ public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (justNumber.IsSet && justNumber.Value == null)
- throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly.");
-
return new NumberOnly(justNumber);
}
@@ -168,7 +165,10 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (numberOnly.JustNumberOption.IsSet)
- writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ if (numberOnly.JustNumberOption.Value != null)
+ writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ else
+ writer.WriteNull("JustNumber");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index b2fced877576..d0146bbf4380 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -200,18 +200,6 @@ public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReade
}
}
- if (bars.IsSet && bars.Value == null)
- throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (deprecatedRef.IsSet && deprecatedRef.Value == null)
- throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid);
}
@@ -239,15 +227,6 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj
///
public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
{
- if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
-
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
writer.WritePropertyName("bars");
@@ -259,7 +238,10 @@ public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields ob
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions);
}
if (objectWithDeprecatedFields.IdOption.IsSet)
- writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ if (objectWithDeprecatedFields.IdOption.Value != null)
+ writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (objectWithDeprecatedFields.UuidOption.IsSet)
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
index fff55dc03b4b..22adf3949caf 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
@@ -327,24 +327,6 @@ public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (complete.IsSet && complete.Value == null)
- throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order.");
-
- if (petId.IsSet && petId.Value == null)
- throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order.");
-
- if (quantity.IsSet && quantity.Value == null)
- throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order.");
-
- if (shipDate.IsSet && shipDate.Value == null)
- throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order.");
-
return new Order(complete, id, petId, quantity, shipDate, status);
}
@@ -373,19 +355,34 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
if (order.CompleteOption.IsSet)
- writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ if (order.CompleteOption.Value != null)
+ writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ else
+ writer.WriteNull("complete");
if (order.IdOption.IsSet)
- writer.WriteNumber("id", order.IdOption.Value!.Value);
+ if (order.IdOption.Value != null)
+ writer.WriteNumber("id", order.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (order.PetIdOption.IsSet)
- writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ if (order.PetIdOption.Value != null)
+ writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ else
+ writer.WriteNull("petId");
if (order.QuantityOption.IsSet)
- writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ if (order.QuantityOption.Value != null)
+ writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ else
+ writer.WriteNull("quantity");
if (order.ShipDateOption.IsSet)
- writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ if (order.ShipDateOption.Value != null)
+ writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ else
+ writer.WriteNull("shipDate");
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
index 834a7f3516f1..77807c15742c 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -177,15 +177,6 @@ public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (myBoolean.IsSet && myBoolean.Value == null)
- throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite.");
-
- if (myNumber.IsSet && myNumber.Value == null)
- throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite.");
-
- if (myString.IsSet && myString.Value == null)
- throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite.");
-
return new OuterComposite(myBoolean, myNumber, myString);
}
@@ -213,14 +204,17 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
- if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
-
if (outerComposite.MyBooleanOption.IsSet)
- writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ if (outerComposite.MyBooleanOption.Value != null)
+ writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ else
+ writer.WriteNull("my_boolean");
if (outerComposite.MyNumberOption.IsSet)
- writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ if (outerComposite.MyNumberOption.Value != null)
+ writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ else
+ writer.WriteNull("my_number");
if (outerComposite.MyStringOption.IsSet)
writer.WriteString("my_string", outerComposite.MyString);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
index fc68eb27a177..8dafe7f105ae 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
@@ -320,18 +320,6 @@ public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (photoUrls.IsSet && photoUrls.Value == null)
throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet.");
- if (category.IsSet && category.Value == null)
- throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet.");
-
- if (tags.IsSet && tags.Value == null)
- throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet.");
-
return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags);
}
@@ -365,12 +353,6 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
if (pet.PhotoUrls == null)
throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
-
- if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
-
writer.WriteString("name", pet.Name);
writer.WritePropertyName("photoUrls");
@@ -381,7 +363,10 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions);
}
if (pet.IdOption.IsSet)
- writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ if (pet.IdOption.Value != null)
+ writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 4d458434bb1c..cf6451028c6e 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -195,12 +195,6 @@ public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst.");
-
- if (baz.IsSet && baz.Value == null)
- throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst.");
-
return new ReadOnlyFirst(bar, baz);
}
@@ -228,12 +222,6 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J
///
public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
{
- if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst.");
-
- if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
-
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
index 074d0e77ee37..f4c4908b2237 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2080,39 +2080,6 @@ public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null)
throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
- if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass.");
-
- if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass.");
-
return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!);
}
@@ -2146,12 +2113,6 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
if (requiredClass.RequiredNotnullableStringProp == null)
throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
- if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
-
- if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
-
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
writer.WritePropertyName("required_notnullable_array_of_string");
@@ -2176,10 +2137,16 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp);
if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet)
- writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ if (requiredClass.NotRequiredNotnullableDatePropOption.Value != null)
+ writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ else
+ writer.WriteNull("not_required_notnullable_date_prop");
if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet)
- writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.Value != null)
+ writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ else
+ writer.WriteNull("not_required_notnullableinteger_prop");
if (requiredClass.NotRequiredNullableDatePropOption.IsSet)
if (requiredClass.NotRequiredNullableDatePropOption.Value != null)
@@ -2199,16 +2166,28 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions);
}
if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet)
- writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.Value != null)
+ writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_boolean_prop");
if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet)
- writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.Value != null)
+ writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ else
+ writer.WriteNull("notrequired_notnullable_datetime_prop");
if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer");
if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer_only");
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
@@ -2221,7 +2200,10 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp);
if (requiredClass.NotrequiredNotnullableUuidOption.IsSet)
- writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableUuidOption.Value != null)
+ writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_uuid");
if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet)
if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
index 1c1f18fd1dec..5ce641729926 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
@@ -180,15 +180,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result.");
-
return new Result(code, data, uuid);
}
@@ -216,15 +207,6 @@ public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions)
{
- if (result.CodeOption.IsSet && result.Code == null)
- throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result.");
-
- if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
-
- if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
-
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
index 1544a23710c1..81617782b527 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
@@ -192,12 +192,6 @@ public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (varLock.IsSet && varLock.Value == null)
throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return.");
- if (varReturn.IsSet && varReturn.Value == null)
- throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return.");
-
- if (varUnsafe.IsSet && varUnsafe.Value == null)
- throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return.");
-
return new Return(varLock.Value!, varAbstract.Value!, varReturn, varUnsafe);
}
@@ -228,9 +222,6 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
if (varReturn.Lock == null)
throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
- if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
-
writer.WriteString("lock", varReturn.Lock);
if (varReturn.Abstract != null)
@@ -239,7 +230,10 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
writer.WriteNull("abstract");
if (varReturn.VarReturnOption.IsSet)
- writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ if (varReturn.VarReturnOption.Value != null)
+ writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ else
+ writer.WriteNull("return");
if (varReturn.UnsafeOption.IsSet)
writer.WriteString("unsafe", varReturn.Unsafe);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index 28b65b24ecf3..782fe80540e1 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -157,12 +157,6 @@ public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (role.IsSet && role.Value == null)
- throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash.");
-
- if (roleUuid.IsSet && roleUuid.Value == null)
- throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash.");
-
return new RolesReportsHash(role, roleUuid);
}
@@ -190,16 +184,16 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null)
- throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash.");
-
if (rolesReportsHash.RoleOption.IsSet)
{
writer.WritePropertyName("role");
JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions);
}
if (rolesReportsHash.RoleUuidOption.IsSet)
- writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ if (rolesReportsHash.RoleUuidOption.Value != null)
+ writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ else
+ writer.WriteNull("role_uuid");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index ba4ac84d8e20..c723f857b80e 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -137,9 +137,6 @@ public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Typ
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole.");
-
return new RolesReportsHashRole(name);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null)
- throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole.");
-
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 0cf9332983fd..f054cff9e4ea 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -157,12 +157,6 @@ public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varSpecialModelName.IsSet && varSpecialModelName.Value == null)
- throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName.");
-
- if (specialPropertyName.IsSet && specialPropertyName.Value == null)
- throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName.");
-
return new SpecialModelName(varSpecialModelName, specialPropertyName);
}
@@ -190,14 +184,14 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN
///
public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
{
- if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null)
- throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName.");
-
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
if (specialModelName.SpecialPropertyNameOption.IsSet)
- writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ if (specialModelName.SpecialPropertyNameOption.Value != null)
+ writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ else
+ writer.WriteNull("$special[property.name]");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
index a350814f2c88..a5735f5f5452 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
@@ -157,12 +157,6 @@ public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag.");
-
return new Tag(id, name);
}
@@ -190,11 +184,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
- if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
-
if (tag.IdOption.IsSet)
- writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ if (tag.IdOption.Value != null)
+ writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (tag.NameOption.IsSet)
writer.WriteString("name", tag.Name);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index b5f8d88ed68d..4ffddf1d1aef 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -137,9 +137,6 @@ public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8Jso
}
}
- if (value.IsSet && value.Value == null)
- throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList.");
-
return new TestCollectionEndingWithWordList(value);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList.");
-
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index 37acae1c88df..d58f1e6dc695 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -137,9 +137,6 @@ public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader u
}
}
- if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject.");
-
return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject.");
-
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
writer.WritePropertyName("TestCollectionEndingWithWordList");
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index de60d7c2281f..b9052313836c 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -137,9 +137,6 @@ public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonR
}
}
- if (someProperty.IsSet && someProperty.Value == null)
- throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest.");
-
return new TestInlineFreeformAdditionalPropertiesRequest(someProperty);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
{
- if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null)
- throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest.");
-
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
index df0deacac70e..d7310e182744 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
@@ -181,15 +181,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult.");
-
return new TestResult(code, data, uuid);
}
@@ -217,12 +208,6 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
- if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
-
- if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
-
if (testResult.CodeOption.IsSet)
{
var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
index 6af3ab9df35c..4a72b6988ae5 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
@@ -362,33 +362,6 @@ public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (email.IsSet && email.Value == null)
- throw new ArgumentNullException(nameof(email), "Property is not nullable for class User.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class User.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User.");
-
- if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null)
- throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User.");
-
- if (password.IsSet && password.Value == null)
- throw new ArgumentNullException(nameof(password), "Property is not nullable for class User.");
-
- if (phone.IsSet && phone.Value == null)
- throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User.");
-
- if (userStatus.IsSet && userStatus.Value == null)
- throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User.");
-
- if (username.IsSet && username.Value == null)
- throw new ArgumentNullException(nameof(username), "Property is not nullable for class User.");
-
return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username);
}
@@ -416,27 +389,6 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
{
- if (user.EmailOption.IsSet && user.Email == null)
- throw new ArgumentNullException(nameof(user.Email), "Property is required for class User.");
-
- if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
-
- if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
-
- if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
-
- if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
-
- if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
-
- if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
-
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
{
@@ -460,7 +412,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("firstName", user.FirstName);
if (user.IdOption.IsSet)
- writer.WriteNumber("id", user.IdOption.Value!.Value);
+ if (user.IdOption.Value != null)
+ writer.WriteNumber("id", user.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (user.LastNameOption.IsSet)
writer.WriteString("lastName", user.LastName);
@@ -485,7 +440,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("phone", user.Phone);
if (user.UserStatusOption.IsSet)
- writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ if (user.UserStatusOption.Value != null)
+ writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ else
+ writer.WriteNull("userStatus");
if (user.UsernameOption.IsSet)
writer.WriteString("username", user.Username);
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
index 080a4f804022..2aa92b38bcca 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
@@ -176,12 +176,6 @@ public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale.");
- if (hasBaleen.IsSet && hasBaleen.Value == null)
- throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale.");
-
- if (hasTeeth.IsSet && hasTeeth.Value == null)
- throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale.");
-
return new Whale(className.Value!, hasBaleen, hasTeeth);
}
@@ -215,10 +209,16 @@ public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOp
writer.WriteString("className", whale.ClassName);
if (whale.HasBaleenOption.IsSet)
- writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ if (whale.HasBaleenOption.Value != null)
+ writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ else
+ writer.WriteNull("hasBaleen");
if (whale.HasTeethOption.IsSet)
- writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ if (whale.HasTeethOption.Value != null)
+ writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ else
+ writer.WriteNull("hasTeeth");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
index 0d0e7222c42b..297c28839930 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
@@ -238,9 +238,6 @@ public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra.");
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra.");
-
return new Zebra(className.Value!, type);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 74792442fd0e..8976bef3505e 100644
--- a/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net8/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -205,9 +205,6 @@ public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null)
- throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass.");
-
return new ZeroBasedEnumClass(zeroBasedEnum);
}
diff --git a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
index d81a3689e6e1..d2d90cc36c59 100644
--- a/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net8/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
@@ -158,12 +158,6 @@ public override NowGet200Response Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (now.IsSet && now.Value == null)
- throw new ArgumentNullException(nameof(now), "Property is not nullable for class NowGet200Response.");
-
- if (today.IsSet && today.Value == null)
- throw new ArgumentNullException(nameof(today), "Property is not nullable for class NowGet200Response.");
-
return new NowGet200Response(now, today);
}
@@ -192,10 +186,16 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
if (nowGet200Response.NowOption.IsSet)
- writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
+ if (nowGet200Response.NowOption.Value != null)
+ writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
+ else
+ writer.WriteNull("now");
if (nowGet200Response.TodayOption.IsSet)
- writer.WriteString("today", nowGet200Response.TodayOption.Value!.Value.ToString(TodayFormat));
+ if (nowGet200Response.TodayOption.Value != null)
+ writer.WriteString("today", nowGet200Response.TodayOption.Value!.Value.ToString(TodayFormat));
+ else
+ writer.WriteNull("today");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Adult.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Adult.cs
index e5c016d2627d..c1770389a70b 100644
--- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Adult.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Adult.cs
@@ -134,18 +134,6 @@ public override Adult Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (children.IsSet && children.Value == null)
- throw new ArgumentNullException(nameof(children), "Property is not nullable for class Adult.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Adult.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Adult.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Adult.");
-
return new Adult(children, firstName, lastName);
}
@@ -173,15 +161,6 @@ public override void Write(Utf8JsonWriter writer, Adult adult, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Adult adult, JsonSerializerOptions jsonSerializerOptions)
{
- if (adult.ChildrenOption.IsSet && adult.Children == null)
- throw new ArgumentNullException(nameof(adult.Children), "Property is required for class Adult.");
-
- if (adult.FirstNameOption.IsSet && adult.FirstName == null)
- throw new ArgumentNullException(nameof(adult.FirstName), "Property is required for class Adult.");
-
- if (adult.LastNameOption.IsSet && adult.LastName == null)
- throw new ArgumentNullException(nameof(adult.LastName), "Property is required for class Adult.");
-
if (adult.ChildrenOption.IsSet)
{
writer.WritePropertyName("children");
diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Child.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Child.cs
index 94cfd4f4aa62..7a142b9ac41e 100644
--- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Child.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Child.cs
@@ -154,21 +154,6 @@ public override Child Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (age.IsSet && age.Value == null)
- throw new ArgumentNullException(nameof(age), "Property is not nullable for class Child.");
-
- if (boosterSeat.IsSet && boosterSeat.Value == null)
- throw new ArgumentNullException(nameof(boosterSeat), "Property is not nullable for class Child.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Child.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Child.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Child.");
-
return new Child(age, boosterSeat, firstName, lastName);
}
@@ -196,17 +181,17 @@ public override void Write(Utf8JsonWriter writer, Child child, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Child child, JsonSerializerOptions jsonSerializerOptions)
{
- if (child.FirstNameOption.IsSet && child.FirstName == null)
- throw new ArgumentNullException(nameof(child.FirstName), "Property is required for class Child.");
-
- if (child.LastNameOption.IsSet && child.LastName == null)
- throw new ArgumentNullException(nameof(child.LastName), "Property is required for class Child.");
-
if (child.AgeOption.IsSet)
- writer.WriteNumber("age", child.AgeOption.Value!.Value);
+ if (child.AgeOption.Value != null)
+ writer.WriteNumber("age", child.AgeOption.Value!.Value);
+ else
+ writer.WriteNull("age");
if (child.BoosterSeatOption.IsSet)
- writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value);
+ if (child.BoosterSeatOption.Value != null)
+ writer.WriteBoolean("boosterSeat", child.BoosterSeatOption.Value!.Value);
+ else
+ writer.WriteNull("boosterSeat");
if (child.FirstNameOption.IsSet)
writer.WriteString("firstName", child.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Person.cs b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Person.cs
index 6da989d4e3a7..a9dedb4eb4f0 100644
--- a/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Person.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AllOf/src/Org.OpenAPITools/Model/Person.cs
@@ -186,15 +186,6 @@ public override Person Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class Person.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class Person.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Person.");
-
return new Person(firstName, lastName);
}
@@ -232,12 +223,6 @@ public override void Write(Utf8JsonWriter writer, Person person, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Person person, JsonSerializerOptions jsonSerializerOptions)
{
- if (person.FirstNameOption.IsSet && person.FirstName == null)
- throw new ArgumentNullException(nameof(person.FirstName), "Property is required for class Person.");
-
- if (person.LastNameOption.IsSet && person.LastName == null)
- throw new ArgumentNullException(nameof(person.LastName), "Property is required for class Person.");
-
if (person.FirstNameOption.IsSet)
writer.WriteString("firstName", person.FirstName);
diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
index dd3528fa42a4..0826aac5f1a9 100644
--- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -136,9 +136,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
index 170ad4b54dac..1cf95d5690f7 100644
--- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
index 89b223fa5dbb..480e908afc63 100644
--- a/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AnyOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -185,9 +185,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -234,9 +231,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
index 8531edebf731..d51f01d8357e 100644
--- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Apple.cs
@@ -135,9 +135,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -165,9 +162,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
index 93897bf0b56a..1f90d47f25d4 100644
--- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Banana.cs
@@ -135,9 +135,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -166,7 +163,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
index 60e3c31c6a4f..b53b9cc8694d 100644
--- a/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/AnyOfNoCompare/src/Org.OpenAPITools/Model/Fruit.cs
@@ -184,9 +184,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -233,9 +230,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
index fd37515f54a2..54a14058a611 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Activity.cs
@@ -136,9 +136,6 @@ public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
}
}
- if (activityOutputs.IsSet && activityOutputs.Value == null)
- throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity.");
-
return new Activity(activityOutputs);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
{
- if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null)
- throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity.");
-
if (activity.ActivityOutputsOption.IsSet)
{
writer.WritePropertyName("activity_outputs");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 80ab5ec04b8d..29e3444ae64f 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -156,12 +156,6 @@ public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8
}
}
- if (prop1.IsSet && prop1.Value == null)
- throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
- if (prop2.IsSet && prop2.Value == null)
- throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
return new ActivityOutputElementRepresentation(prop1, prop2);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent
///
public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
{
- if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation.");
-
- if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
-
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index de2cf7f84849..f56f4f0806fc 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -277,27 +277,6 @@ public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader
}
}
- if (emptyMap.IsSet && emptyMap.Value == null)
- throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapProperty.IsSet && mapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass.");
-
return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString);
}
@@ -325,27 +304,6 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi
///
public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
-
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
index 1e87e6de2950..4d36ec4ce4d4 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Animal.cs
@@ -172,9 +172,6 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
-
return new Animal(color);
}
@@ -212,9 +209,6 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
{
- if (animal.ColorOption.IsSet && animal.Color == null)
- throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal.");
-
writer.WriteString("className", animal.ClassName);
if (animal.ColorOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
index c7fa501c3c5d..65aa7bce8814 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -176,15 +176,6 @@ public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse.");
-
- if (message.IsSet && message.Value == null)
- throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse.");
-
return new ApiResponse(code, message, type);
}
@@ -212,14 +203,11 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
-
- if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
-
if (apiResponse.CodeOption.IsSet)
- writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ if (apiResponse.CodeOption.Value != null)
+ writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ else
+ writer.WriteNull("code");
if (apiResponse.MessageOption.IsSet)
writer.WriteString("message", apiResponse.Message);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
index 601dae95aa1a..233780d0bbf9 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Apple.cs
@@ -206,15 +206,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (colorCode.IsSet && colorCode.Value == null)
- throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple.");
-
- if (cultivar.IsSet && cultivar.Value == null)
- throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple.");
-
- if (origin.IsSet && origin.Value == null)
- throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple.");
-
return new Apple(colorCode, cultivar, origin);
}
@@ -242,15 +233,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.ColorCodeOption.IsSet && apple.ColorCode == null)
- throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple.");
-
- if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
-
- if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
-
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
index fdef147cb388..603ed8b1b7c8 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -148,9 +148,6 @@ public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (cultivar.IsSet && cultivar.Value == null)
throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq.");
- if (mealy.IsSet && mealy.Value == null)
- throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq.");
-
return new AppleReq(cultivar.Value!, mealy);
}
@@ -184,7 +181,10 @@ public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerial
writer.WriteString("cultivar", appleReq.Cultivar);
if (appleReq.MealyOption.IsSet)
- writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ if (appleReq.MealyOption.Value != null)
+ writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ else
+ writer.WriteNull("mealy");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index a09872cef811..e32622955178 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -136,9 +136,6 @@ public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader,
}
}
- if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly.");
-
return new ArrayOfArrayOfNumberOnly(arrayArrayNumber);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly.");
-
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index c338f29efc9d..31f190ea0bd6 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -136,9 +136,6 @@ public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (arrayNumber.IsSet && arrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly.");
-
return new ArrayOfNumberOnly(arrayNumber);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly.");
-
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
index 04609b245365..2543e616837a 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -176,15 +176,6 @@ public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
}
}
- if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest.");
-
- if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest.");
-
- if (arrayOfString.IsSet && arrayOfString.Value == null)
- throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest.");
-
return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString);
}
@@ -212,15 +203,6 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
-
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
writer.WritePropertyName("array_array_of_integer");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
index cf0ee9cdb1aa..19d507f22d49 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (lengthCm.IsSet && lengthCm.Value == null)
- throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana.");
-
return new Banana(lengthCm);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.LengthCmOption.IsSet)
- writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ if (banana.LengthCmOption.Value != null)
+ writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ else
+ writer.WriteNull("lengthCm");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
index 10375771f80b..e53a11f03ac0 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -148,9 +148,6 @@ public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
if (lengthCm.IsSet && lengthCm.Value == null)
throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq.");
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq.");
-
return new BananaReq(lengthCm.Value!.Value!, sweet);
}
@@ -181,7 +178,10 @@ public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeri
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
- writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ if (bananaReq.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
index 133845a991f0..d23f06b49376 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -237,24 +237,6 @@ public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (aTTNAME.IsSet && aTTNAME.Value == null)
- throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization.");
-
- if (capitalCamel.IsSet && capitalCamel.Value == null)
- throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization.");
-
- if (capitalSnake.IsSet && capitalSnake.Value == null)
- throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization.");
-
- if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null)
- throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization.");
-
- if (smallCamel.IsSet && smallCamel.Value == null)
- throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization.");
-
- if (smallSnake.IsSet && smallSnake.Value == null)
- throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization.");
-
return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake);
}
@@ -282,24 +264,6 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization,
///
public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
{
- if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null)
- throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
-
- if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
-
- if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
-
- if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
-
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
index 4887c6c7aff7..6933fd651942 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Cat.cs
@@ -135,12 +135,6 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat.");
-
- if (declawed.IsSet && declawed.Value == null)
- throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat.");
-
return new Cat(color, declawed);
}
@@ -168,16 +162,16 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
{
- if (cat.ColorOption.IsSet && cat.Color == null)
- throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat.");
-
writer.WriteString("className", cat.ClassName);
if (cat.ColorOption.IsSet)
writer.WriteString("color", cat.Color);
if (cat.DeclawedOption.IsSet)
- writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ if (cat.DeclawedOption.Value != null)
+ writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ else
+ writer.WriteNull("declawed");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
index 936d8dc8b225..f40778b17c24 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Category.cs
@@ -152,9 +152,6 @@ public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (!name.IsSet)
throw new ArgumentException("Property is required for class Category.", nameof(name));
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category.");
-
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category.");
@@ -189,7 +186,10 @@ public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerial
throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
if (category.IdOption.IsSet)
- writer.WriteNumber("id", category.IdOption.Value!.Value);
+ if (category.IdOption.Value != null)
+ writer.WriteNumber("id", category.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
writer.WriteString("name", category.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
index c37ba2ec211e..cc30d23ad45c 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -189,9 +189,6 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
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.");
@@ -222,9 +219,6 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
{
- if (childCat.NameOption.IsSet && childCat.Name == null)
- throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat.");
-
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
index 5a199576ee29..77511092b81d 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -136,9 +136,6 @@ public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel.");
-
return new ClassModel(varClass);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
{
- if (classModel.ClassOption.IsSet && classModel.Class == null)
- throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel.");
-
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index d908fed19a3a..363b5623e0b3 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -142,9 +142,6 @@ public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null)
- throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass.");
-
return new DateOnlyClass(dateOnlyProperty);
}
@@ -173,7 +170,10 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
- writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ if (dateOnlyClass.DateOnlyPropertyOption.Value != null)
+ writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ else
+ writer.WriteNull("dateOnlyProperty");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index 68e0836b632f..40d33cc49b93 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -136,9 +136,6 @@ public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject.");
-
return new DeprecatedObject(name);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj
///
public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null)
- throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject.");
-
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
index 05eb0781cfe7..3336440935fa 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Dog.cs
@@ -135,12 +135,6 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog.");
- if (breed.IsSet && breed.Value == null)
- throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog.");
-
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog.");
-
return new Dog(breed, color);
}
@@ -168,12 +162,6 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
{
- if (dog.BreedOption.IsSet && dog.Breed == null)
- throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog.");
-
- if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
-
writer.WriteString("className", dog.ClassName);
if (dog.BreedOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
index 1668434a783f..36cda7a41304 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Drawing.cs
@@ -196,12 +196,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (mainShape.IsSet && mainShape.Value == null)
- throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing.");
-
- if (shapes.IsSet && shapes.Value == null)
- throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing.");
-
return new Drawing(mainShape, nullableShape, shapeOrNull, shapes);
}
@@ -229,12 +223,6 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
{
- if (drawing.MainShapeOption.IsSet && drawing.MainShape == null)
- throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing.");
-
- if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
-
if (drawing.MainShapeOption.IsSet)
{
writer.WritePropertyName("mainShape");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
index 9a6f097e92c2..0dbae86d74c1 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -290,12 +290,6 @@ public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (arrayEnum.IsSet && arrayEnum.Value == null)
- throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays.");
-
- if (justSymbol.IsSet && justSymbol.Value == null)
- throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays.");
-
return new EnumArrays(arrayEnum, justSymbol);
}
@@ -323,9 +317,6 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
{
- if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null)
- throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays.");
-
if (enumArrays.ArrayEnumOption.IsSet)
{
writer.WritePropertyName("array_enum");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
index ea7a5bd26988..a6ad620905e3 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -791,27 +791,6 @@ public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (enumStringRequired.IsSet && enumStringRequired.Value == null)
throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest.");
- if (enumInteger.IsSet && enumInteger.Value == null)
- throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest.");
-
- if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest.");
-
- if (enumNumber.IsSet && enumNumber.Value == null)
- throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest.");
-
- if (enumString.IsSet && enumString.Value == null)
- throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest.");
-
- if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest.");
-
- if (outerEnumInteger.IsSet && outerEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest.");
-
- if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest.");
-
return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue);
}
@@ -842,13 +821,22 @@ public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerial
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
- writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ if (enumTest.EnumIntegerOption.Value != null)
+ writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer");
if (enumTest.EnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ if (enumTest.EnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer_only");
if (enumTest.EnumNumberOption.IsSet)
- writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ if (enumTest.EnumNumberOption.Value != null)
+ writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ else
+ writer.WriteNull("enum_number");
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
writer.WriteString("enum_string", enumStringRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
index dab2e4e27b36..bb17ff53d25e 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/File.cs
@@ -137,9 +137,6 @@ public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (sourceURI.IsSet && sourceURI.Value == null)
- throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File.");
-
return new File(sourceURI);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
{
- if (file.SourceURIOption.IsSet && file.SourceURI == null)
- throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File.");
-
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index 971a81e9c8c4..1b428026dab9 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -156,12 +156,6 @@ public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (file.IsSet && file.Value == null)
- throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass.");
-
- if (files.IsSet && files.Value == null)
- throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass.");
-
return new FileSchemaTestClass(file, files);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema
///
public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass.");
-
- if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
-
if (fileSchemaTestClass.FileOption.IsSet)
{
writer.WritePropertyName("file");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
index b8128f4c3e45..1649f2dcca78 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Foo.cs
@@ -136,9 +136,6 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
-
return new Foo(bar);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
- if (foo.BarOption.IsSet && foo.Bar == null)
- throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");
-
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index f4e54444c7ee..4b315c651541 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -136,9 +136,6 @@ public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Ty
}
}
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse.");
-
return new FooGetDefaultResponse(varString);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe
///
public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null)
- throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse.");
-
if (fooGetDefaultResponse.StringOption.IsSet)
{
writer.WritePropertyName("string");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
index 9e4b3c23fe8a..81285ddae396 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -847,75 +847,6 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (stringFormattedAsDecimalRequired.IsSet && stringFormattedAsDecimalRequired.Value == null)
throw new ArgumentNullException(nameof(stringFormattedAsDecimalRequired), "Property is not nullable for class FormatTest.");
- if (binary.IsSet && binary.Value == null)
- throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest.");
-
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest.");
-
- if (varDecimal.IsSet && varDecimal.Value == null)
- throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest.");
-
- if (varDouble.IsSet && varDouble.Value == null)
- throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName2.IsSet && duplicatePropertyName2.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName2), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName.IsSet && duplicatePropertyName.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName), "Property is not nullable for class FormatTest.");
-
- if (varFloat.IsSet && varFloat.Value == null)
- throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest.");
-
- if (int32.IsSet && int32.Value == null)
- throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest.");
-
- if (int32Range.IsSet && int32Range.Value == null)
- throw new ArgumentNullException(nameof(int32Range), "Property is not nullable for class FormatTest.");
-
- if (int64.IsSet && int64.Value == null)
- throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest.");
-
- if (int64Negative.IsSet && int64Negative.Value == null)
- throw new ArgumentNullException(nameof(int64Negative), "Property is not nullable for class FormatTest.");
-
- if (int64NegativeExclusive.IsSet && int64NegativeExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64NegativeExclusive), "Property is not nullable for class FormatTest.");
-
- if (int64Positive.IsSet && int64Positive.Value == null)
- throw new ArgumentNullException(nameof(int64Positive), "Property is not nullable for class FormatTest.");
-
- if (int64PositiveExclusive.IsSet && int64PositiveExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64PositiveExclusive), "Property is not nullable for class FormatTest.");
-
- if (integer.IsSet && integer.Value == null)
- throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest.");
-
- if (patternWithBackslash.IsSet && patternWithBackslash.Value == null)
- throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigits.IsSet && patternWithDigits.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest.");
-
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest.");
-
- if (stringFormattedAsDecimal.IsSet && stringFormattedAsDecimal.Value == null)
- throw new ArgumentNullException(nameof(stringFormattedAsDecimal), "Property is not nullable for class FormatTest.");
-
- if (unsignedInteger.IsSet && unsignedInteger.Value == null)
- throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest.");
-
- if (unsignedLong.IsSet && unsignedLong.Value == null)
- throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
-
return new FormatTest(varByte.Value!, date.Value!.Value!, number.Value!.Value!, password.Value!, stringFormattedAsDecimalRequired.Value!.Value!, binary, dateTime, varDecimal, varDouble, duplicatePropertyName2, duplicatePropertyName, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, stringFormattedAsDecimal, unsignedInteger, unsignedLong, uuid);
}
@@ -949,27 +880,6 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
if (formatTest.Password == null)
throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
-
- if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
-
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
@@ -986,7 +896,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions);
}
if (formatTest.DateTimeOption.IsSet)
- writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (formatTest.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (formatTest.DecimalOption.IsSet)
{
@@ -994,7 +907,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions);
}
if (formatTest.DoubleOption.IsSet)
- writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ if (formatTest.DoubleOption.Value != null)
+ writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ else
+ writer.WriteNull("double");
if (formatTest.DuplicatePropertyName2Option.IsSet)
writer.WriteString("duplicate_property_name", formatTest.DuplicatePropertyName2);
@@ -1003,31 +919,58 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("@duplicate_property_name", formatTest.DuplicatePropertyName);
if (formatTest.FloatOption.IsSet)
- writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ if (formatTest.FloatOption.Value != null)
+ writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ else
+ writer.WriteNull("float");
if (formatTest.Int32Option.IsSet)
- writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ if (formatTest.Int32Option.Value != null)
+ writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ else
+ writer.WriteNull("int32");
if (formatTest.Int32RangeOption.IsSet)
- writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ if (formatTest.Int32RangeOption.Value != null)
+ writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ else
+ writer.WriteNull("int32Range");
if (formatTest.Int64Option.IsSet)
- writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ if (formatTest.Int64Option.Value != null)
+ writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ else
+ writer.WriteNull("int64");
if (formatTest.Int64NegativeOption.IsSet)
- writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ if (formatTest.Int64NegativeOption.Value != null)
+ writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ else
+ writer.WriteNull("int64Negative");
if (formatTest.Int64NegativeExclusiveOption.IsSet)
- writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ if (formatTest.Int64NegativeExclusiveOption.Value != null)
+ writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64NegativeExclusive");
if (formatTest.Int64PositiveOption.IsSet)
- writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ if (formatTest.Int64PositiveOption.Value != null)
+ writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64Positive");
if (formatTest.Int64PositiveExclusiveOption.IsSet)
- writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ if (formatTest.Int64PositiveExclusiveOption.Value != null)
+ writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64PositiveExclusive");
if (formatTest.IntegerOption.IsSet)
- writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ if (formatTest.IntegerOption.Value != null)
+ writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ else
+ writer.WriteNull("integer");
if (formatTest.PatternWithBackslashOption.IsSet)
writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash);
@@ -1042,16 +985,28 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("string", formatTest.String);
if (formatTest.StringFormattedAsDecimalOption.IsSet)
- writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ if (formatTest.StringFormattedAsDecimalOption.Value != null)
+ writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ else
+ writer.WriteNull("string_formatted_as_decimal");
if (formatTest.UnsignedIntegerOption.IsSet)
- writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ if (formatTest.UnsignedIntegerOption.Value != null)
+ writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_integer");
if (formatTest.UnsignedLongOption.IsSet)
- writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ if (formatTest.UnsignedLongOption.Value != null)
+ writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_long");
if (formatTest.UuidOption.IsSet)
- writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ if (formatTest.UuidOption.Value != null)
+ writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
index eb12679ed27d..04d8d8c83466 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Fruit.cs
@@ -174,9 +174,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -210,9 +207,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
index d751e8154524..5b8b0531a47a 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -178,9 +178,6 @@ public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -227,9 +224,6 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (gmFruit.ColorOption.IsSet && gmFruit.Color == null)
- throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit.");
-
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index 50826dd0da5d..0c383b3b1776 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -197,12 +197,6 @@ public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typ
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly.");
-
- if (foo.IsSet && foo.Value == null)
- throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly.");
-
return new HasOnlyReadOnly(bar, foo);
}
@@ -230,12 +224,6 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl
///
public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly.");
-
- if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
-
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
index ddf0d615fd3c..774eddc243a8 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/List.cs
@@ -136,9 +136,6 @@ public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (var123List.IsSet && var123List.Value == null)
- throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List.");
-
return new List(var123List);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
{
- if (list.Var123ListOption.IsSet && list.Var123List == null)
- throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List.");
-
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index 5993dd82adc8..3525a34b369b 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -156,12 +156,6 @@ public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (escapedLiteralString.IsSet && escapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
- if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
return new LiteralStringClass(escapedLiteralString, unescapedLiteralString);
}
@@ -189,12 +183,6 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri
///
public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass.");
-
- if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
-
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
index 06668cf78934..0b68a78dfbd5 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MapTest.cs
@@ -262,18 +262,6 @@ public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (directMap.IsSet && directMap.Value == null)
- throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest.");
-
- if (indirectMap.IsSet && indirectMap.Value == null)
- throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest.");
-
- if (mapMapOfString.IsSet && mapMapOfString.Value == null)
- throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest.");
-
- if (mapOfEnumString.IsSet && mapOfEnumString.Value == null)
- throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest.");
-
return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString);
}
@@ -301,18 +289,6 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest.");
-
- if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
-
- if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
-
- if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
-
if (mapTest.DirectMapOption.IsSet)
{
writer.WritePropertyName("direct_map");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index 266cbf7f9d2e..15d32a530899 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -136,9 +136,6 @@ public override MixedAnyOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf.");
-
return new MixedAnyOf(content);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null)
- throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf.");
-
if (mixedAnyOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
index 4d5b2c6d94cf..6be715c794d8 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -136,9 +136,6 @@ public override MixedOneOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf.");
-
return new MixedOneOf(content);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null)
- throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf.");
-
if (mixedOneOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 968a64762901..ce2e08e1e124 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -208,18 +208,6 @@ public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonRea
}
}
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (map.IsSet && map.Value == null)
- throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuidWithPattern.IsSet && uuidWithPattern.Value == null)
- throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern);
}
@@ -247,11 +235,11 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
-
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
- writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet)
{
@@ -259,10 +247,16 @@ public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalP
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions);
}
if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet)
- writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value != null)
+ writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet)
- writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value != null)
+ writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ else
+ writer.WriteNull("uuid_with_pattern");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
index 6b56e6017b15..7cfbb5a22316 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -136,9 +136,6 @@ public override MixedSubId Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId.");
-
return new MixedSubId(id);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null)
- throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId.");
-
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
index 76bffb1856bc..7186223e67b6 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -156,12 +156,6 @@ public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response.");
-
return new Model200Response(varClass, name);
}
@@ -189,14 +183,14 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo
///
public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
{
- if (model200Response.ClassOption.IsSet && model200Response.Class == null)
- throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response.");
-
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
if (model200Response.NameOption.IsSet)
- writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ if (model200Response.NameOption.Value != null)
+ writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ else
+ writer.WriteNull("name");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
index 7a982b8104d3..eeb350f4964f 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -136,9 +136,6 @@ public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (varClient.IsSet && varClient.Value == null)
- throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient.");
-
return new ModelClient(varClient);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
{
- if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null)
- throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient.");
-
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
index 100ccfa20e5b..86e07bbbbc4c 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Name.cs
@@ -236,15 +236,6 @@ public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (varName.IsSet && varName.Value == null)
throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name.");
- if (property.IsSet && property.Value == null)
- throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name.");
-
- if (snakeCase.IsSet && snakeCase.Value == null)
- throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name.");
-
- if (var123Number.IsSet && var123Number.Value == null)
- throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name.");
-
return new Name(varName.Value!.Value!, property, snakeCase, var123Number);
}
@@ -272,19 +263,22 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
{
- if (name.PropertyOption.IsSet && name.Property == null)
- throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name.");
-
writer.WriteNumber("name", name.VarName);
if (name.PropertyOption.IsSet)
writer.WriteString("property", name.Property);
if (name.SnakeCaseOption.IsSet)
- writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ if (name.SnakeCaseOption.Value != null)
+ writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ else
+ writer.WriteNull("snake_case");
if (name.Var123NumberOption.IsSet)
- writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ if (name.Var123NumberOption.Value != null)
+ writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ else
+ writer.WriteNull("123Number");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
index db7eaa8f675c..f7ff8f69bb9e 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -366,12 +366,6 @@ public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass.");
-
- if (objectItemsNullable.IsSet && objectItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass.");
-
return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp);
}
@@ -399,12 +393,6 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J
///
public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass.");
-
- if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
-
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
index f7ae912c05e6..b315d41bb949 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -136,9 +136,6 @@ public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (justNumber.IsSet && justNumber.Value == null)
- throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly.");
-
return new NumberOnly(justNumber);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (numberOnly.JustNumberOption.IsSet)
- writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ if (numberOnly.JustNumberOption.Value != null)
+ writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ else
+ writer.WriteNull("JustNumber");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index fa4f88b3ecdd..1317bd91560c 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -199,18 +199,6 @@ public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReade
}
}
- if (bars.IsSet && bars.Value == null)
- throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (deprecatedRef.IsSet && deprecatedRef.Value == null)
- throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid);
}
@@ -238,15 +226,6 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj
///
public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
{
- if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
-
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
writer.WritePropertyName("bars");
@@ -258,7 +237,10 @@ public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields ob
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions);
}
if (objectWithDeprecatedFields.IdOption.IsSet)
- writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ if (objectWithDeprecatedFields.IdOption.Value != null)
+ writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (objectWithDeprecatedFields.UuidOption.IsSet)
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
index c4c43309bec1..bf0237990786 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Order.cs
@@ -326,24 +326,6 @@ public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (complete.IsSet && complete.Value == null)
- throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order.");
-
- if (petId.IsSet && petId.Value == null)
- throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order.");
-
- if (quantity.IsSet && quantity.Value == null)
- throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order.");
-
- if (shipDate.IsSet && shipDate.Value == null)
- throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order.");
-
return new Order(complete, id, petId, quantity, shipDate, status);
}
@@ -372,19 +354,34 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
if (order.CompleteOption.IsSet)
- writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ if (order.CompleteOption.Value != null)
+ writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ else
+ writer.WriteNull("complete");
if (order.IdOption.IsSet)
- writer.WriteNumber("id", order.IdOption.Value!.Value);
+ if (order.IdOption.Value != null)
+ writer.WriteNumber("id", order.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (order.PetIdOption.IsSet)
- writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ if (order.PetIdOption.Value != null)
+ writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ else
+ writer.WriteNull("petId");
if (order.QuantityOption.IsSet)
- writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ if (order.QuantityOption.Value != null)
+ writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ else
+ writer.WriteNull("quantity");
if (order.ShipDateOption.IsSet)
- writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ if (order.ShipDateOption.Value != null)
+ writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ else
+ writer.WriteNull("shipDate");
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
index 4428479e0485..f9c6a1474bae 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -176,15 +176,6 @@ public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (myBoolean.IsSet && myBoolean.Value == null)
- throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite.");
-
- if (myNumber.IsSet && myNumber.Value == null)
- throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite.");
-
- if (myString.IsSet && myString.Value == null)
- throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite.");
-
return new OuterComposite(myBoolean, myNumber, myString);
}
@@ -212,14 +203,17 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
- if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
-
if (outerComposite.MyBooleanOption.IsSet)
- writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ if (outerComposite.MyBooleanOption.Value != null)
+ writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ else
+ writer.WriteNull("my_boolean");
if (outerComposite.MyNumberOption.IsSet)
- writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ if (outerComposite.MyNumberOption.Value != null)
+ writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ else
+ writer.WriteNull("my_number");
if (outerComposite.MyStringOption.IsSet)
writer.WriteString("my_string", outerComposite.MyString);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
index 56b981a0e2ad..9557747c46dc 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Pet.cs
@@ -319,18 +319,6 @@ public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (photoUrls.IsSet && photoUrls.Value == null)
throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet.");
- if (category.IsSet && category.Value == null)
- throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet.");
-
- if (tags.IsSet && tags.Value == null)
- throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet.");
-
return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags);
}
@@ -364,12 +352,6 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
if (pet.PhotoUrls == null)
throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
-
- if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
-
writer.WriteString("name", pet.Name);
writer.WritePropertyName("photoUrls");
@@ -380,7 +362,10 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions);
}
if (pet.IdOption.IsSet)
- writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ if (pet.IdOption.Value != null)
+ writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index a48fcb21dbef..17016304c4dd 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -194,12 +194,6 @@ public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst.");
-
- if (baz.IsSet && baz.Value == null)
- throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst.");
-
return new ReadOnlyFirst(bar, baz);
}
@@ -227,12 +221,6 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J
///
public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
{
- if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst.");
-
- if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
-
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
index 0c7dc7eab56f..ce661233c93b 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2079,39 +2079,6 @@ public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null)
throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
- if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass.");
-
- if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass.");
-
return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!);
}
@@ -2145,12 +2112,6 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
if (requiredClass.RequiredNotnullableStringProp == null)
throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
- if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
-
- if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
-
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
writer.WritePropertyName("required_notnullable_array_of_string");
@@ -2175,10 +2136,16 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp);
if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet)
- writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ if (requiredClass.NotRequiredNotnullableDatePropOption.Value != null)
+ writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ else
+ writer.WriteNull("not_required_notnullable_date_prop");
if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet)
- writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.Value != null)
+ writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ else
+ writer.WriteNull("not_required_notnullableinteger_prop");
if (requiredClass.NotRequiredNullableDatePropOption.IsSet)
if (requiredClass.NotRequiredNullableDatePropOption.Value != null)
@@ -2198,16 +2165,28 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions);
}
if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet)
- writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.Value != null)
+ writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_boolean_prop");
if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet)
- writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.Value != null)
+ writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ else
+ writer.WriteNull("notrequired_notnullable_datetime_prop");
if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer");
if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer_only");
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
@@ -2220,7 +2199,10 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp);
if (requiredClass.NotrequiredNotnullableUuidOption.IsSet)
- writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableUuidOption.Value != null)
+ writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_uuid");
if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet)
if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
index 6119748b2992..0c8e9be329f9 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Result.cs
@@ -179,15 +179,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result.");
-
return new Result(code, data, uuid);
}
@@ -215,15 +206,6 @@ public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions)
{
- if (result.CodeOption.IsSet && result.Code == null)
- throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result.");
-
- if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
-
- if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
-
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
index 6276a3a8c8ae..752ea2da319e 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Return.cs
@@ -191,12 +191,6 @@ public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (varLock.IsSet && varLock.Value == null)
throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return.");
- if (varReturn.IsSet && varReturn.Value == null)
- throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return.");
-
- if (varUnsafe.IsSet && varUnsafe.Value == null)
- throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return.");
-
return new Return(varLock.Value!, varAbstract.Value!, varReturn, varUnsafe);
}
@@ -227,9 +221,6 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
if (varReturn.Lock == null)
throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
- if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
-
writer.WriteString("lock", varReturn.Lock);
if (varReturn.Abstract != null)
@@ -238,7 +229,10 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
writer.WriteNull("abstract");
if (varReturn.VarReturnOption.IsSet)
- writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ if (varReturn.VarReturnOption.Value != null)
+ writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ else
+ writer.WriteNull("return");
if (varReturn.UnsafeOption.IsSet)
writer.WriteString("unsafe", varReturn.Unsafe);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index 245ea1053e5d..3219fdf99dde 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -156,12 +156,6 @@ public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (role.IsSet && role.Value == null)
- throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash.");
-
- if (roleUuid.IsSet && roleUuid.Value == null)
- throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash.");
-
return new RolesReportsHash(role, roleUuid);
}
@@ -189,16 +183,16 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null)
- throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash.");
-
if (rolesReportsHash.RoleOption.IsSet)
{
writer.WritePropertyName("role");
JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions);
}
if (rolesReportsHash.RoleUuidOption.IsSet)
- writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ if (rolesReportsHash.RoleUuidOption.Value != null)
+ writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ else
+ writer.WriteNull("role_uuid");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index 684ca8e8b515..45e278a334ff 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -136,9 +136,6 @@ public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Typ
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole.");
-
return new RolesReportsHashRole(name);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null)
- throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole.");
-
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 1fce10cd7823..bd2b77eb5ce9 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -156,12 +156,6 @@ public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varSpecialModelName.IsSet && varSpecialModelName.Value == null)
- throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName.");
-
- if (specialPropertyName.IsSet && specialPropertyName.Value == null)
- throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName.");
-
return new SpecialModelName(varSpecialModelName, specialPropertyName);
}
@@ -189,14 +183,14 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN
///
public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
{
- if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null)
- throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName.");
-
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
if (specialModelName.SpecialPropertyNameOption.IsSet)
- writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ if (specialModelName.SpecialPropertyNameOption.Value != null)
+ writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ else
+ writer.WriteNull("$special[property.name]");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
index a6c404c940b8..089fc767f734 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Tag.cs
@@ -156,12 +156,6 @@ public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag.");
-
return new Tag(id, name);
}
@@ -189,11 +183,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
- if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
-
if (tag.IdOption.IsSet)
- writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ if (tag.IdOption.Value != null)
+ writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (tag.NameOption.IsSet)
writer.WriteString("name", tag.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index f1a1940574ee..5a0353bce33d 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -136,9 +136,6 @@ public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8Jso
}
}
- if (value.IsSet && value.Value == null)
- throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList.");
-
return new TestCollectionEndingWithWordList(value);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList.");
-
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index 5cbf9d28f57e..b86b7b610c6e 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -136,9 +136,6 @@ public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader u
}
}
- if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject.");
-
return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject.");
-
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
writer.WritePropertyName("TestCollectionEndingWithWordList");
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index 102413449b18..e626f9975ce5 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -136,9 +136,6 @@ public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonR
}
}
- if (someProperty.IsSet && someProperty.Value == null)
- throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest.");
-
return new TestInlineFreeformAdditionalPropertiesRequest(someProperty);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
{
- if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null)
- throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest.");
-
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
index e7829b5974ee..dfe6d8e7a887 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/TestResult.cs
@@ -180,15 +180,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult.");
-
return new TestResult(code, data, uuid);
}
@@ -216,12 +207,6 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
- if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
-
- if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
-
if (testResult.CodeOption.IsSet)
{
var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
index d02f765752fd..af12ad03e1bc 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/User.cs
@@ -361,33 +361,6 @@ public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (email.IsSet && email.Value == null)
- throw new ArgumentNullException(nameof(email), "Property is not nullable for class User.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class User.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User.");
-
- if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null)
- throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User.");
-
- if (password.IsSet && password.Value == null)
- throw new ArgumentNullException(nameof(password), "Property is not nullable for class User.");
-
- if (phone.IsSet && phone.Value == null)
- throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User.");
-
- if (userStatus.IsSet && userStatus.Value == null)
- throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User.");
-
- if (username.IsSet && username.Value == null)
- throw new ArgumentNullException(nameof(username), "Property is not nullable for class User.");
-
return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username);
}
@@ -415,27 +388,6 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
{
- if (user.EmailOption.IsSet && user.Email == null)
- throw new ArgumentNullException(nameof(user.Email), "Property is required for class User.");
-
- if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
-
- if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
-
- if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
-
- if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
-
- if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
-
- if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
-
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
{
@@ -459,7 +411,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("firstName", user.FirstName);
if (user.IdOption.IsSet)
- writer.WriteNumber("id", user.IdOption.Value!.Value);
+ if (user.IdOption.Value != null)
+ writer.WriteNumber("id", user.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (user.LastNameOption.IsSet)
writer.WriteString("lastName", user.LastName);
@@ -484,7 +439,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("phone", user.Phone);
if (user.UserStatusOption.IsSet)
- writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ if (user.UserStatusOption.Value != null)
+ writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ else
+ writer.WriteNull("userStatus");
if (user.UsernameOption.IsSet)
writer.WriteString("username", user.Username);
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
index 3d5ad4a7d676..07d268952b5f 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Whale.cs
@@ -175,12 +175,6 @@ public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale.");
- if (hasBaleen.IsSet && hasBaleen.Value == null)
- throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale.");
-
- if (hasTeeth.IsSet && hasTeeth.Value == null)
- throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale.");
-
return new Whale(className.Value!, hasBaleen, hasTeeth);
}
@@ -214,10 +208,16 @@ public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOp
writer.WriteString("className", whale.ClassName);
if (whale.HasBaleenOption.IsSet)
- writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ if (whale.HasBaleenOption.Value != null)
+ writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ else
+ writer.WriteNull("hasBaleen");
if (whale.HasTeethOption.IsSet)
- writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ if (whale.HasTeethOption.Value != null)
+ writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ else
+ writer.WriteNull("hasTeeth");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
index 4ca12a36d096..716132325475 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/Zebra.cs
@@ -237,9 +237,6 @@ public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra.");
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra.");
-
return new Zebra(className.Value!, type);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index dfb395124397..59474730b6af 100644
--- a/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/NullReferenceTypes/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -204,9 +204,6 @@ public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null)
- throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass.");
-
return new ZeroBasedEnumClass(zeroBasedEnum);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Apple.cs
index dd3528fa42a4..0826aac5f1a9 100644
--- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Apple.cs
@@ -136,9 +136,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (kind.IsSet && kind.Value == null)
- throw new ArgumentNullException(nameof(kind), "Property is not nullable for class Apple.");
-
return new Apple(kind);
}
@@ -166,9 +163,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.KindOption.IsSet && apple.Kind == null)
- throw new ArgumentNullException(nameof(apple.Kind), "Property is required for class Apple.");
-
if (apple.KindOption.IsSet)
writer.WriteString("kind", apple.Kind);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Banana.cs
index 170ad4b54dac..1cf95d5690f7 100644
--- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Banana.cs
@@ -136,9 +136,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (count.IsSet && count.Value == null)
- throw new ArgumentNullException(nameof(count), "Property is not nullable for class Banana.");
-
return new Banana(count);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.CountOption.IsSet)
- writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ if (banana.CountOption.Value != null)
+ writer.WriteNumber("count", banana.CountOption.Value!.Value);
+ else
+ writer.WriteNull("count");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
index 056f2c03af8d..e1ad75e01636 100644
--- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Fruit.cs
@@ -202,9 +202,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -241,9 +238,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Orange.cs b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Orange.cs
index eaa0165ba6c1..05777f379c18 100644
--- a/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Orange.cs
+++ b/samples/client/petstore/csharp/generichost/net9/OneOf/src/Org.OpenAPITools/Model/Orange.cs
@@ -136,9 +136,6 @@ public override Orange Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class Orange.");
-
return new Orange(sweet);
}
@@ -167,7 +164,10 @@ public override void Write(Utf8JsonWriter writer, Orange orange, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Orange orange, JsonSerializerOptions jsonSerializerOptions)
{
if (orange.SweetOption.IsSet)
- writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
+ if (orange.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", orange.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
index 65645b2e4829..e68030d8dfbe 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Activity.cs
@@ -137,9 +137,6 @@ public override Activity Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
}
}
- if (activityOutputs.IsSet && activityOutputs.Value == null)
- throw new ArgumentNullException(nameof(activityOutputs), "Property is not nullable for class Activity.");
-
return new Activity(activityOutputs);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, Activity activity, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, Activity activity, JsonSerializerOptions jsonSerializerOptions)
{
- if (activity.ActivityOutputsOption.IsSet && activity.ActivityOutputs == null)
- throw new ArgumentNullException(nameof(activity.ActivityOutputs), "Property is required for class Activity.");
-
if (activity.ActivityOutputsOption.IsSet)
{
writer.WritePropertyName("activity_outputs");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
index 728bbb0c349e..455cb9784010 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ActivityOutputElementRepresentation.cs
@@ -157,12 +157,6 @@ public override ActivityOutputElementRepresentation Read(ref Utf8JsonReader utf8
}
}
- if (prop1.IsSet && prop1.Value == null)
- throw new ArgumentNullException(nameof(prop1), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
- if (prop2.IsSet && prop2.Value == null)
- throw new ArgumentNullException(nameof(prop2), "Property is not nullable for class ActivityOutputElementRepresentation.");
-
return new ActivityOutputElementRepresentation(prop1, prop2);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, ActivityOutputElementRepresent
///
public void WriteProperties(Utf8JsonWriter writer, ActivityOutputElementRepresentation activityOutputElementRepresentation, JsonSerializerOptions jsonSerializerOptions)
{
- if (activityOutputElementRepresentation.Prop1Option.IsSet && activityOutputElementRepresentation.Prop1 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop1), "Property is required for class ActivityOutputElementRepresentation.");
-
- if (activityOutputElementRepresentation.Prop2Option.IsSet && activityOutputElementRepresentation.Prop2 == null)
- throw new ArgumentNullException(nameof(activityOutputElementRepresentation.Prop2), "Property is required for class ActivityOutputElementRepresentation.");
-
if (activityOutputElementRepresentation.Prop1Option.IsSet)
writer.WriteString("prop1", activityOutputElementRepresentation.Prop1);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
index 9fa35476f70c..5d2b8f501bc5 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AdditionalPropertiesClass.cs
@@ -278,27 +278,6 @@ public override AdditionalPropertiesClass Read(ref Utf8JsonReader utf8JsonReader
}
}
- if (emptyMap.IsSet && emptyMap.Value == null)
- throw new ArgumentNullException(nameof(emptyMap), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapOfMapProperty.IsSet && mapOfMapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapOfMapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapProperty.IsSet && mapProperty.Value == null)
- throw new ArgumentNullException(nameof(mapProperty), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype1.IsSet && mapWithUndeclaredPropertiesAnytype1.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype1), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype2.IsSet && mapWithUndeclaredPropertiesAnytype2.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype2), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesAnytype3.IsSet && mapWithUndeclaredPropertiesAnytype3.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesAnytype3), "Property is not nullable for class AdditionalPropertiesClass.");
-
- if (mapWithUndeclaredPropertiesString.IsSet && mapWithUndeclaredPropertiesString.Value == null)
- throw new ArgumentNullException(nameof(mapWithUndeclaredPropertiesString), "Property is not nullable for class AdditionalPropertiesClass.");
-
return new AdditionalPropertiesClass(anytype1, emptyMap, mapOfMapProperty, mapProperty, mapWithUndeclaredPropertiesAnytype1, mapWithUndeclaredPropertiesAnytype2, mapWithUndeclaredPropertiesAnytype3, mapWithUndeclaredPropertiesString);
}
@@ -326,27 +305,6 @@ public override void Write(Utf8JsonWriter writer, AdditionalPropertiesClass addi
///
public void WriteProperties(Utf8JsonWriter writer, AdditionalPropertiesClass additionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (additionalPropertiesClass.EmptyMapOption.IsSet && additionalPropertiesClass.EmptyMap == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.EmptyMap), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapOfMapPropertyOption.IsSet && additionalPropertiesClass.MapOfMapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapOfMapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapPropertyOption.IsSet && additionalPropertiesClass.MapProperty == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapProperty), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype1), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype2), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3Option.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3 == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesAnytype3), "Property is required for class AdditionalPropertiesClass.");
-
- if (additionalPropertiesClass.MapWithUndeclaredPropertiesStringOption.IsSet && additionalPropertiesClass.MapWithUndeclaredPropertiesString == null)
- throw new ArgumentNullException(nameof(additionalPropertiesClass.MapWithUndeclaredPropertiesString), "Property is required for class AdditionalPropertiesClass.");
-
if (additionalPropertiesClass.Anytype1Option.IsSet)
if (additionalPropertiesClass.Anytype1Option.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
index 37a0519bbd6b..ed53b38d189a 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Animal.cs
@@ -173,9 +173,6 @@ public override Animal Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Animal.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Animal.");
-
return new Animal(color);
}
@@ -213,9 +210,6 @@ public override void Write(Utf8JsonWriter writer, Animal animal, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Animal animal, JsonSerializerOptions jsonSerializerOptions)
{
- if (animal.ColorOption.IsSet && animal.Color == null)
- throw new ArgumentNullException(nameof(animal.Color), "Property is required for class Animal.");
-
writer.WriteString("className", animal.ClassName);
if (animal.ColorOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
index bf92565f9a2e..ca3b2c1fdfd9 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ApiResponse.cs
@@ -177,15 +177,6 @@ public override ApiResponse Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class ApiResponse.");
-
- if (message.IsSet && message.Value == null)
- throw new ArgumentNullException(nameof(message), "Property is not nullable for class ApiResponse.");
-
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class ApiResponse.");
-
return new ApiResponse(code, message, type);
}
@@ -213,14 +204,11 @@ public override void Write(Utf8JsonWriter writer, ApiResponse apiResponse, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ApiResponse apiResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (apiResponse.MessageOption.IsSet && apiResponse.Message == null)
- throw new ArgumentNullException(nameof(apiResponse.Message), "Property is required for class ApiResponse.");
-
- if (apiResponse.TypeOption.IsSet && apiResponse.Type == null)
- throw new ArgumentNullException(nameof(apiResponse.Type), "Property is required for class ApiResponse.");
-
if (apiResponse.CodeOption.IsSet)
- writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ if (apiResponse.CodeOption.Value != null)
+ writer.WriteNumber("code", apiResponse.CodeOption.Value!.Value);
+ else
+ writer.WriteNull("code");
if (apiResponse.MessageOption.IsSet)
writer.WriteString("message", apiResponse.Message);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
index 3dab90bbeb36..e1c0f65ea706 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Apple.cs
@@ -207,15 +207,6 @@ public override Apple Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (colorCode.IsSet && colorCode.Value == null)
- throw new ArgumentNullException(nameof(colorCode), "Property is not nullable for class Apple.");
-
- if (cultivar.IsSet && cultivar.Value == null)
- throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class Apple.");
-
- if (origin.IsSet && origin.Value == null)
- throw new ArgumentNullException(nameof(origin), "Property is not nullable for class Apple.");
-
return new Apple(colorCode, cultivar, origin);
}
@@ -243,15 +234,6 @@ public override void Write(Utf8JsonWriter writer, Apple apple, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Apple apple, JsonSerializerOptions jsonSerializerOptions)
{
- if (apple.ColorCodeOption.IsSet && apple.ColorCode == null)
- throw new ArgumentNullException(nameof(apple.ColorCode), "Property is required for class Apple.");
-
- if (apple.CultivarOption.IsSet && apple.Cultivar == null)
- throw new ArgumentNullException(nameof(apple.Cultivar), "Property is required for class Apple.");
-
- if (apple.OriginOption.IsSet && apple.Origin == null)
- throw new ArgumentNullException(nameof(apple.Origin), "Property is required for class Apple.");
-
if (apple.ColorCodeOption.IsSet)
writer.WriteString("color_code", apple.ColorCode);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
index cbb5ea8f0849..c8344376a888 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/AppleReq.cs
@@ -149,9 +149,6 @@ public override AppleReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (cultivar.IsSet && cultivar.Value == null)
throw new ArgumentNullException(nameof(cultivar), "Property is not nullable for class AppleReq.");
- if (mealy.IsSet && mealy.Value == null)
- throw new ArgumentNullException(nameof(mealy), "Property is not nullable for class AppleReq.");
-
return new AppleReq(cultivar.Value!, mealy);
}
@@ -185,7 +182,10 @@ public void WriteProperties(Utf8JsonWriter writer, AppleReq appleReq, JsonSerial
writer.WriteString("cultivar", appleReq.Cultivar);
if (appleReq.MealyOption.IsSet)
- writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ if (appleReq.MealyOption.Value != null)
+ writer.WriteBoolean("mealy", appleReq.MealyOption.Value!.Value);
+ else
+ writer.WriteNull("mealy");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
index cd3309a5900e..31072802633a 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfArrayOfNumberOnly.cs
@@ -137,9 +137,6 @@ public override ArrayOfArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader,
}
}
- if (arrayArrayNumber.IsSet && arrayArrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayNumber), "Property is not nullable for class ArrayOfArrayOfNumberOnly.");
-
return new ArrayOfArrayOfNumberOnly(arrayArrayNumber);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly array
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet && arrayOfArrayOfNumberOnly.ArrayArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfArrayOfNumberOnly.ArrayArrayNumber), "Property is required for class ArrayOfArrayOfNumberOnly.");
-
if (arrayOfArrayOfNumberOnly.ArrayArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
index 90b6e4a8bd14..c605df6473f5 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayOfNumberOnly.cs
@@ -137,9 +137,6 @@ public override ArrayOfNumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (arrayNumber.IsSet && arrayNumber.Value == null)
- throw new ArgumentNullException(nameof(arrayNumber), "Property is not nullable for class ArrayOfNumberOnly.");
-
return new ArrayOfNumberOnly(arrayNumber);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumbe
///
public void WriteProperties(Utf8JsonWriter writer, ArrayOfNumberOnly arrayOfNumberOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayOfNumberOnly.ArrayNumberOption.IsSet && arrayOfNumberOnly.ArrayNumber == null)
- throw new ArgumentNullException(nameof(arrayOfNumberOnly.ArrayNumber), "Property is required for class ArrayOfNumberOnly.");
-
if (arrayOfNumberOnly.ArrayNumberOption.IsSet)
{
writer.WritePropertyName("ArrayNumber");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
index 6be410aad46e..33316827318d 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ArrayTest.cs
@@ -177,15 +177,6 @@ public override ArrayTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
}
}
- if (arrayArrayOfInteger.IsSet && arrayArrayOfInteger.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfInteger), "Property is not nullable for class ArrayTest.");
-
- if (arrayArrayOfModel.IsSet && arrayArrayOfModel.Value == null)
- throw new ArgumentNullException(nameof(arrayArrayOfModel), "Property is not nullable for class ArrayTest.");
-
- if (arrayOfString.IsSet && arrayOfString.Value == null)
- throw new ArgumentNullException(nameof(arrayOfString), "Property is not nullable for class ArrayTest.");
-
return new ArrayTest(arrayArrayOfInteger, arrayArrayOfModel, arrayOfString);
}
@@ -213,15 +204,6 @@ public override void Write(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSeria
///
public void WriteProperties(Utf8JsonWriter writer, ArrayTest arrayTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (arrayTest.ArrayArrayOfIntegerOption.IsSet && arrayTest.ArrayArrayOfInteger == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfInteger), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayArrayOfModelOption.IsSet && arrayTest.ArrayArrayOfModel == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayArrayOfModel), "Property is required for class ArrayTest.");
-
- if (arrayTest.ArrayOfStringOption.IsSet && arrayTest.ArrayOfString == null)
- throw new ArgumentNullException(nameof(arrayTest.ArrayOfString), "Property is required for class ArrayTest.");
-
if (arrayTest.ArrayArrayOfIntegerOption.IsSet)
{
writer.WritePropertyName("array_array_of_integer");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
index 1352e54c4091..74829deb5fb1 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Banana.cs
@@ -137,9 +137,6 @@ public override Banana Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (lengthCm.IsSet && lengthCm.Value == null)
- throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class Banana.");
-
return new Banana(lengthCm);
}
@@ -168,7 +165,10 @@ public override void Write(Utf8JsonWriter writer, Banana banana, JsonSerializerO
public void WriteProperties(Utf8JsonWriter writer, Banana banana, JsonSerializerOptions jsonSerializerOptions)
{
if (banana.LengthCmOption.IsSet)
- writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ if (banana.LengthCmOption.Value != null)
+ writer.WriteNumber("lengthCm", banana.LengthCmOption.Value!.Value);
+ else
+ writer.WriteNull("lengthCm");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
index 584505890fdc..0c9228dac974 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/BananaReq.cs
@@ -149,9 +149,6 @@ public override BananaReq Read(ref Utf8JsonReader utf8JsonReader, Type typeToCon
if (lengthCm.IsSet && lengthCm.Value == null)
throw new ArgumentNullException(nameof(lengthCm), "Property is not nullable for class BananaReq.");
- if (sweet.IsSet && sweet.Value == null)
- throw new ArgumentNullException(nameof(sweet), "Property is not nullable for class BananaReq.");
-
return new BananaReq(lengthCm.Value!.Value!, sweet);
}
@@ -182,7 +179,10 @@ public void WriteProperties(Utf8JsonWriter writer, BananaReq bananaReq, JsonSeri
writer.WriteNumber("lengthCm", bananaReq.LengthCm);
if (bananaReq.SweetOption.IsSet)
- writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ if (bananaReq.SweetOption.Value != null)
+ writer.WriteBoolean("sweet", bananaReq.SweetOption.Value!.Value);
+ else
+ writer.WriteNull("sweet");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
index e36a343dc5e2..7507fbf15047 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Capitalization.cs
@@ -238,24 +238,6 @@ public override Capitalization Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (aTTNAME.IsSet && aTTNAME.Value == null)
- throw new ArgumentNullException(nameof(aTTNAME), "Property is not nullable for class Capitalization.");
-
- if (capitalCamel.IsSet && capitalCamel.Value == null)
- throw new ArgumentNullException(nameof(capitalCamel), "Property is not nullable for class Capitalization.");
-
- if (capitalSnake.IsSet && capitalSnake.Value == null)
- throw new ArgumentNullException(nameof(capitalSnake), "Property is not nullable for class Capitalization.");
-
- if (sCAETHFlowPoints.IsSet && sCAETHFlowPoints.Value == null)
- throw new ArgumentNullException(nameof(sCAETHFlowPoints), "Property is not nullable for class Capitalization.");
-
- if (smallCamel.IsSet && smallCamel.Value == null)
- throw new ArgumentNullException(nameof(smallCamel), "Property is not nullable for class Capitalization.");
-
- if (smallSnake.IsSet && smallSnake.Value == null)
- throw new ArgumentNullException(nameof(smallSnake), "Property is not nullable for class Capitalization.");
-
return new Capitalization(aTTNAME, capitalCamel, capitalSnake, sCAETHFlowPoints, smallCamel, smallSnake);
}
@@ -283,24 +265,6 @@ public override void Write(Utf8JsonWriter writer, Capitalization capitalization,
///
public void WriteProperties(Utf8JsonWriter writer, Capitalization capitalization, JsonSerializerOptions jsonSerializerOptions)
{
- if (capitalization.ATT_NAMEOption.IsSet && capitalization.ATT_NAME == null)
- throw new ArgumentNullException(nameof(capitalization.ATT_NAME), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalCamelOption.IsSet && capitalization.CapitalCamel == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalCamel), "Property is required for class Capitalization.");
-
- if (capitalization.CapitalSnakeOption.IsSet && capitalization.CapitalSnake == null)
- throw new ArgumentNullException(nameof(capitalization.CapitalSnake), "Property is required for class Capitalization.");
-
- if (capitalization.SCAETHFlowPointsOption.IsSet && capitalization.SCAETHFlowPoints == null)
- throw new ArgumentNullException(nameof(capitalization.SCAETHFlowPoints), "Property is required for class Capitalization.");
-
- if (capitalization.SmallCamelOption.IsSet && capitalization.SmallCamel == null)
- throw new ArgumentNullException(nameof(capitalization.SmallCamel), "Property is required for class Capitalization.");
-
- if (capitalization.SmallSnakeOption.IsSet && capitalization.SmallSnake == null)
- throw new ArgumentNullException(nameof(capitalization.SmallSnake), "Property is required for class Capitalization.");
-
if (capitalization.ATT_NAMEOption.IsSet)
writer.WriteString("ATT_NAME", capitalization.ATT_NAME);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
index 00b32d995aa3..2451fa64efcb 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Cat.cs
@@ -136,12 +136,6 @@ public override Cat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Cat.");
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Cat.");
-
- if (declawed.IsSet && declawed.Value == null)
- throw new ArgumentNullException(nameof(declawed), "Property is not nullable for class Cat.");
-
return new Cat(color, declawed);
}
@@ -169,16 +163,16 @@ public override void Write(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Cat cat, JsonSerializerOptions jsonSerializerOptions)
{
- if (cat.ColorOption.IsSet && cat.Color == null)
- throw new ArgumentNullException(nameof(cat.Color), "Property is required for class Cat.");
-
writer.WriteString("className", cat.ClassName);
if (cat.ColorOption.IsSet)
writer.WriteString("color", cat.Color);
if (cat.DeclawedOption.IsSet)
- writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ if (cat.DeclawedOption.Value != null)
+ writer.WriteBoolean("declawed", cat.DeclawedOption.Value!.Value);
+ else
+ writer.WriteNull("declawed");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
index 0369f8f37e97..40e17252a708 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Category.cs
@@ -153,9 +153,6 @@ public override Category Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (!name.IsSet)
throw new ArgumentException("Property is required for class Category.", nameof(name));
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Category.");
-
if (name.IsSet && name.Value == null)
throw new ArgumentNullException(nameof(name), "Property is not nullable for class Category.");
@@ -190,7 +187,10 @@ public void WriteProperties(Utf8JsonWriter writer, Category category, JsonSerial
throw new ArgumentNullException(nameof(category.Name), "Property is required for class Category.");
if (category.IdOption.IsSet)
- writer.WriteNumber("id", category.IdOption.Value!.Value);
+ if (category.IdOption.Value != null)
+ writer.WriteNumber("id", category.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
writer.WriteString("name", category.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
index 4131c59373af..219f38158e71 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ChildCat.cs
@@ -190,9 +190,6 @@ public override ChildCat Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
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.");
@@ -223,9 +220,6 @@ public override void Write(Utf8JsonWriter writer, ChildCat childCat, JsonSeriali
///
public void WriteProperties(Utf8JsonWriter writer, ChildCat childCat, JsonSerializerOptions jsonSerializerOptions)
{
- if (childCat.NameOption.IsSet && childCat.Name == null)
- throw new ArgumentNullException(nameof(childCat.Name), "Property is required for class ChildCat.");
-
if (childCat.NameOption.IsSet)
writer.WriteString("name", childCat.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
index e38fad89dbad..b29dc2232486 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ClassModel.cs
@@ -137,9 +137,6 @@ public override ClassModel Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class ClassModel.");
-
return new ClassModel(varClass);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ClassModel classModel, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, ClassModel classModel, JsonSerializerOptions jsonSerializerOptions)
{
- if (classModel.ClassOption.IsSet && classModel.Class == null)
- throw new ArgumentNullException(nameof(classModel.Class), "Property is required for class ClassModel.");
-
if (classModel.ClassOption.IsSet)
writer.WriteString("_class", classModel.Class);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
index 8981331c9e19..cadefcdc9294 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DateOnlyClass.cs
@@ -143,9 +143,6 @@ public override DateOnlyClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (dateOnlyProperty.IsSet && dateOnlyProperty.Value == null)
- throw new ArgumentNullException(nameof(dateOnlyProperty), "Property is not nullable for class DateOnlyClass.");
-
return new DateOnlyClass(dateOnlyProperty);
}
@@ -174,7 +171,10 @@ public override void Write(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, J
public void WriteProperties(Utf8JsonWriter writer, DateOnlyClass dateOnlyClass, JsonSerializerOptions jsonSerializerOptions)
{
if (dateOnlyClass.DateOnlyPropertyOption.IsSet)
- writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ if (dateOnlyClass.DateOnlyPropertyOption.Value != null)
+ writer.WriteString("dateOnlyProperty", dateOnlyClass.DateOnlyPropertyOption.Value!.Value.ToString(DateOnlyPropertyFormat));
+ else
+ writer.WriteNull("dateOnlyProperty");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
index 0b8716d11ff4..209ad029521a 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/DeprecatedObject.cs
@@ -137,9 +137,6 @@ public override DeprecatedObject Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class DeprecatedObject.");
-
return new DeprecatedObject(name);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, DeprecatedObject deprecatedObj
///
public void WriteProperties(Utf8JsonWriter writer, DeprecatedObject deprecatedObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (deprecatedObject.NameOption.IsSet && deprecatedObject.Name == null)
- throw new ArgumentNullException(nameof(deprecatedObject.Name), "Property is required for class DeprecatedObject.");
-
if (deprecatedObject.NameOption.IsSet)
writer.WriteString("name", deprecatedObject.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
index 6129b69ce916..eebabaf3da26 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Dog.cs
@@ -136,12 +136,6 @@ public override Dog Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Dog.");
- if (breed.IsSet && breed.Value == null)
- throw new ArgumentNullException(nameof(breed), "Property is not nullable for class Dog.");
-
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Dog.");
-
return new Dog(breed, color);
}
@@ -169,12 +163,6 @@ public override void Write(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Dog dog, JsonSerializerOptions jsonSerializerOptions)
{
- if (dog.BreedOption.IsSet && dog.Breed == null)
- throw new ArgumentNullException(nameof(dog.Breed), "Property is required for class Dog.");
-
- if (dog.ColorOption.IsSet && dog.Color == null)
- throw new ArgumentNullException(nameof(dog.Color), "Property is required for class Dog.");
-
writer.WriteString("className", dog.ClassName);
if (dog.BreedOption.IsSet)
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
index b6400a09e802..1ca6b42dead8 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Drawing.cs
@@ -197,12 +197,6 @@ public override Drawing Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (mainShape.IsSet && mainShape.Value == null)
- throw new ArgumentNullException(nameof(mainShape), "Property is not nullable for class Drawing.");
-
- if (shapes.IsSet && shapes.Value == null)
- throw new ArgumentNullException(nameof(shapes), "Property is not nullable for class Drawing.");
-
return new Drawing(mainShape, nullableShape, shapeOrNull, shapes);
}
@@ -230,12 +224,6 @@ public override void Write(Utf8JsonWriter writer, Drawing drawing, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, Drawing drawing, JsonSerializerOptions jsonSerializerOptions)
{
- if (drawing.MainShapeOption.IsSet && drawing.MainShape == null)
- throw new ArgumentNullException(nameof(drawing.MainShape), "Property is required for class Drawing.");
-
- if (drawing.ShapesOption.IsSet && drawing.Shapes == null)
- throw new ArgumentNullException(nameof(drawing.Shapes), "Property is required for class Drawing.");
-
if (drawing.MainShapeOption.IsSet)
{
writer.WritePropertyName("mainShape");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
index 5c9774abc417..5a0ae3fe8c07 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumArrays.cs
@@ -291,12 +291,6 @@ public override EnumArrays Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (arrayEnum.IsSet && arrayEnum.Value == null)
- throw new ArgumentNullException(nameof(arrayEnum), "Property is not nullable for class EnumArrays.");
-
- if (justSymbol.IsSet && justSymbol.Value == null)
- throw new ArgumentNullException(nameof(justSymbol), "Property is not nullable for class EnumArrays.");
-
return new EnumArrays(arrayEnum, justSymbol);
}
@@ -324,9 +318,6 @@ public override void Write(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, EnumArrays enumArrays, JsonSerializerOptions jsonSerializerOptions)
{
- if (enumArrays.ArrayEnumOption.IsSet && enumArrays.ArrayEnum == null)
- throw new ArgumentNullException(nameof(enumArrays.ArrayEnum), "Property is required for class EnumArrays.");
-
if (enumArrays.ArrayEnumOption.IsSet)
{
writer.WritePropertyName("array_enum");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
index 897a9bd24efe..4c672d70aaf8 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/EnumTest.cs
@@ -792,27 +792,6 @@ public override EnumTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConv
if (enumStringRequired.IsSet && enumStringRequired.Value == null)
throw new ArgumentNullException(nameof(enumStringRequired), "Property is not nullable for class EnumTest.");
- if (enumInteger.IsSet && enumInteger.Value == null)
- throw new ArgumentNullException(nameof(enumInteger), "Property is not nullable for class EnumTest.");
-
- if (enumIntegerOnly.IsSet && enumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(enumIntegerOnly), "Property is not nullable for class EnumTest.");
-
- if (enumNumber.IsSet && enumNumber.Value == null)
- throw new ArgumentNullException(nameof(enumNumber), "Property is not nullable for class EnumTest.");
-
- if (enumString.IsSet && enumString.Value == null)
- throw new ArgumentNullException(nameof(enumString), "Property is not nullable for class EnumTest.");
-
- if (outerEnumDefaultValue.IsSet && outerEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumDefaultValue), "Property is not nullable for class EnumTest.");
-
- if (outerEnumInteger.IsSet && outerEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(outerEnumInteger), "Property is not nullable for class EnumTest.");
-
- if (outerEnumIntegerDefaultValue.IsSet && outerEnumIntegerDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(outerEnumIntegerDefaultValue), "Property is not nullable for class EnumTest.");
-
return new EnumTest(enumStringRequired.Value!.Value!, enumInteger, enumIntegerOnly, enumNumber, enumString, outerEnum, outerEnumDefaultValue, outerEnumInteger, outerEnumIntegerDefaultValue);
}
@@ -843,13 +822,22 @@ public void WriteProperties(Utf8JsonWriter writer, EnumTest enumTest, JsonSerial
var enumStringRequiredRawValue = EnumTest.EnumStringRequiredEnumToJsonValue(enumTest.EnumStringRequired);
writer.WriteString("enum_string_required", enumStringRequiredRawValue);
if (enumTest.EnumIntegerOption.IsSet)
- writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ if (enumTest.EnumIntegerOption.Value != null)
+ writer.WriteNumber("enum_integer", EnumTest.EnumIntegerEnumToJsonValue(enumTest.EnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer");
if (enumTest.EnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ if (enumTest.EnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("enum_integer_only", EnumTest.EnumIntegerOnlyEnumToJsonValue(enumTest.EnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("enum_integer_only");
if (enumTest.EnumNumberOption.IsSet)
- writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ if (enumTest.EnumNumberOption.Value != null)
+ writer.WriteNumber("enum_number", EnumTest.EnumNumberEnumToJsonValue(enumTest.EnumNumberOption.Value!.Value));
+ else
+ writer.WriteNull("enum_number");
var enumStringRawValue = EnumTest.EnumStringEnumToJsonValue(enumTest.EnumStringOption.Value!.Value);
writer.WriteString("enum_string", enumStringRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/File.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
index bdc5c25e1329..074dc96d0a9f 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/File.cs
@@ -138,9 +138,6 @@ public override File Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (sourceURI.IsSet && sourceURI.Value == null)
- throw new ArgumentNullException(nameof(sourceURI), "Property is not nullable for class File.");
-
return new File(sourceURI);
}
@@ -168,9 +165,6 @@ public override void Write(Utf8JsonWriter writer, File file, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, File file, JsonSerializerOptions jsonSerializerOptions)
{
- if (file.SourceURIOption.IsSet && file.SourceURI == null)
- throw new ArgumentNullException(nameof(file.SourceURI), "Property is required for class File.");
-
if (file.SourceURIOption.IsSet)
writer.WriteString("sourceURI", file.SourceURI);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
index d7c977f2fe4f..f5681591bd7f 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FileSchemaTestClass.cs
@@ -157,12 +157,6 @@ public override FileSchemaTestClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (file.IsSet && file.Value == null)
- throw new ArgumentNullException(nameof(file), "Property is not nullable for class FileSchemaTestClass.");
-
- if (files.IsSet && files.Value == null)
- throw new ArgumentNullException(nameof(files), "Property is not nullable for class FileSchemaTestClass.");
-
return new FileSchemaTestClass(file, files);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, FileSchemaTestClass fileSchema
///
public void WriteProperties(Utf8JsonWriter writer, FileSchemaTestClass fileSchemaTestClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (fileSchemaTestClass.FileOption.IsSet && fileSchemaTestClass.File == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.File), "Property is required for class FileSchemaTestClass.");
-
- if (fileSchemaTestClass.FilesOption.IsSet && fileSchemaTestClass.Files == null)
- throw new ArgumentNullException(nameof(fileSchemaTestClass.Files), "Property is required for class FileSchemaTestClass.");
-
if (fileSchemaTestClass.FileOption.IsSet)
{
writer.WritePropertyName("file");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
index ac4aeb49df5c..d68007dd2828 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Foo.cs
@@ -137,9 +137,6 @@ public override Foo Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class Foo.");
-
return new Foo(bar);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Foo foo, JsonSerializerOptions jsonSerializerOptions)
{
- if (foo.BarOption.IsSet && foo.Bar == null)
- throw new ArgumentNullException(nameof(foo.Bar), "Property is required for class Foo.");
-
if (foo.BarOption.IsSet)
writer.WriteString("bar", foo.Bar);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
index 9f57f4d6318a..bc458b1bd4fe 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FooGetDefaultResponse.cs
@@ -137,9 +137,6 @@ public override FooGetDefaultResponse Read(ref Utf8JsonReader utf8JsonReader, Ty
}
}
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FooGetDefaultResponse.");
-
return new FooGetDefaultResponse(varString);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDe
///
public void WriteProperties(Utf8JsonWriter writer, FooGetDefaultResponse fooGetDefaultResponse, JsonSerializerOptions jsonSerializerOptions)
{
- if (fooGetDefaultResponse.StringOption.IsSet && fooGetDefaultResponse.String == null)
- throw new ArgumentNullException(nameof(fooGetDefaultResponse.String), "Property is required for class FooGetDefaultResponse.");
-
if (fooGetDefaultResponse.StringOption.IsSet)
{
writer.WritePropertyName("string");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
index 3daacf80952d..f00f123ade8b 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/FormatTest.cs
@@ -848,75 +848,6 @@ public override FormatTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
if (stringFormattedAsDecimalRequired.IsSet && stringFormattedAsDecimalRequired.Value == null)
throw new ArgumentNullException(nameof(stringFormattedAsDecimalRequired), "Property is not nullable for class FormatTest.");
- if (binary.IsSet && binary.Value == null)
- throw new ArgumentNullException(nameof(binary), "Property is not nullable for class FormatTest.");
-
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class FormatTest.");
-
- if (varDecimal.IsSet && varDecimal.Value == null)
- throw new ArgumentNullException(nameof(varDecimal), "Property is not nullable for class FormatTest.");
-
- if (varDouble.IsSet && varDouble.Value == null)
- throw new ArgumentNullException(nameof(varDouble), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName2.IsSet && duplicatePropertyName2.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName2), "Property is not nullable for class FormatTest.");
-
- if (duplicatePropertyName.IsSet && duplicatePropertyName.Value == null)
- throw new ArgumentNullException(nameof(duplicatePropertyName), "Property is not nullable for class FormatTest.");
-
- if (varFloat.IsSet && varFloat.Value == null)
- throw new ArgumentNullException(nameof(varFloat), "Property is not nullable for class FormatTest.");
-
- if (int32.IsSet && int32.Value == null)
- throw new ArgumentNullException(nameof(int32), "Property is not nullable for class FormatTest.");
-
- if (int32Range.IsSet && int32Range.Value == null)
- throw new ArgumentNullException(nameof(int32Range), "Property is not nullable for class FormatTest.");
-
- if (int64.IsSet && int64.Value == null)
- throw new ArgumentNullException(nameof(int64), "Property is not nullable for class FormatTest.");
-
- if (int64Negative.IsSet && int64Negative.Value == null)
- throw new ArgumentNullException(nameof(int64Negative), "Property is not nullable for class FormatTest.");
-
- if (int64NegativeExclusive.IsSet && int64NegativeExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64NegativeExclusive), "Property is not nullable for class FormatTest.");
-
- if (int64Positive.IsSet && int64Positive.Value == null)
- throw new ArgumentNullException(nameof(int64Positive), "Property is not nullable for class FormatTest.");
-
- if (int64PositiveExclusive.IsSet && int64PositiveExclusive.Value == null)
- throw new ArgumentNullException(nameof(int64PositiveExclusive), "Property is not nullable for class FormatTest.");
-
- if (integer.IsSet && integer.Value == null)
- throw new ArgumentNullException(nameof(integer), "Property is not nullable for class FormatTest.");
-
- if (patternWithBackslash.IsSet && patternWithBackslash.Value == null)
- throw new ArgumentNullException(nameof(patternWithBackslash), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigits.IsSet && patternWithDigits.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigits), "Property is not nullable for class FormatTest.");
-
- if (patternWithDigitsAndDelimiter.IsSet && patternWithDigitsAndDelimiter.Value == null)
- throw new ArgumentNullException(nameof(patternWithDigitsAndDelimiter), "Property is not nullable for class FormatTest.");
-
- if (varString.IsSet && varString.Value == null)
- throw new ArgumentNullException(nameof(varString), "Property is not nullable for class FormatTest.");
-
- if (stringFormattedAsDecimal.IsSet && stringFormattedAsDecimal.Value == null)
- throw new ArgumentNullException(nameof(stringFormattedAsDecimal), "Property is not nullable for class FormatTest.");
-
- if (unsignedInteger.IsSet && unsignedInteger.Value == null)
- throw new ArgumentNullException(nameof(unsignedInteger), "Property is not nullable for class FormatTest.");
-
- if (unsignedLong.IsSet && unsignedLong.Value == null)
- throw new ArgumentNullException(nameof(unsignedLong), "Property is not nullable for class FormatTest.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class FormatTest.");
-
return new FormatTest(varByte.Value!, date.Value!.Value!, number.Value!.Value!, password.Value!, stringFormattedAsDecimalRequired.Value!.Value!, binary, dateTime, varDecimal, varDouble, duplicatePropertyName2, duplicatePropertyName, varFloat, int32, int32Range, int64, int64Negative, int64NegativeExclusive, int64Positive, int64PositiveExclusive, integer, patternWithBackslash, patternWithDigits, patternWithDigitsAndDelimiter, varString, stringFormattedAsDecimal, unsignedInteger, unsignedLong, uuid);
}
@@ -950,27 +881,6 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
if (formatTest.Password == null)
throw new ArgumentNullException(nameof(formatTest.Password), "Property is required for class FormatTest.");
- if (formatTest.BinaryOption.IsSet && formatTest.Binary == null)
- throw new ArgumentNullException(nameof(formatTest.Binary), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyName2Option.IsSet && formatTest.DuplicatePropertyName2 == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName2), "Property is required for class FormatTest.");
-
- if (formatTest.DuplicatePropertyNameOption.IsSet && formatTest.DuplicatePropertyName == null)
- throw new ArgumentNullException(nameof(formatTest.DuplicatePropertyName), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithBackslashOption.IsSet && formatTest.PatternWithBackslash == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithBackslash), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsOption.IsSet && formatTest.PatternWithDigits == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigits), "Property is required for class FormatTest.");
-
- if (formatTest.PatternWithDigitsAndDelimiterOption.IsSet && formatTest.PatternWithDigitsAndDelimiter == null)
- throw new ArgumentNullException(nameof(formatTest.PatternWithDigitsAndDelimiter), "Property is required for class FormatTest.");
-
- if (formatTest.StringOption.IsSet && formatTest.String == null)
- throw new ArgumentNullException(nameof(formatTest.String), "Property is required for class FormatTest.");
-
writer.WritePropertyName("byte");
JsonSerializer.Serialize(writer, formatTest.Byte, jsonSerializerOptions);
writer.WriteString("date", formatTest.Date.ToString(DateFormat));
@@ -987,7 +897,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Binary, jsonSerializerOptions);
}
if (formatTest.DateTimeOption.IsSet)
- writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (formatTest.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", formatTest.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (formatTest.DecimalOption.IsSet)
{
@@ -995,7 +908,10 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
JsonSerializer.Serialize(writer, formatTest.Decimal, jsonSerializerOptions);
}
if (formatTest.DoubleOption.IsSet)
- writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ if (formatTest.DoubleOption.Value != null)
+ writer.WriteNumber("double", formatTest.DoubleOption.Value!.Value);
+ else
+ writer.WriteNull("double");
if (formatTest.DuplicatePropertyName2Option.IsSet)
writer.WriteString("duplicate_property_name", formatTest.DuplicatePropertyName2);
@@ -1004,31 +920,58 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("@duplicate_property_name", formatTest.DuplicatePropertyName);
if (formatTest.FloatOption.IsSet)
- writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ if (formatTest.FloatOption.Value != null)
+ writer.WriteNumber("float", formatTest.FloatOption.Value!.Value);
+ else
+ writer.WriteNull("float");
if (formatTest.Int32Option.IsSet)
- writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ if (formatTest.Int32Option.Value != null)
+ writer.WriteNumber("int32", formatTest.Int32Option.Value!.Value);
+ else
+ writer.WriteNull("int32");
if (formatTest.Int32RangeOption.IsSet)
- writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ if (formatTest.Int32RangeOption.Value != null)
+ writer.WriteNumber("int32Range", formatTest.Int32RangeOption.Value!.Value);
+ else
+ writer.WriteNull("int32Range");
if (formatTest.Int64Option.IsSet)
- writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ if (formatTest.Int64Option.Value != null)
+ writer.WriteNumber("int64", formatTest.Int64Option.Value!.Value);
+ else
+ writer.WriteNull("int64");
if (formatTest.Int64NegativeOption.IsSet)
- writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ if (formatTest.Int64NegativeOption.Value != null)
+ writer.WriteNumber("int64Negative", formatTest.Int64NegativeOption.Value!.Value);
+ else
+ writer.WriteNull("int64Negative");
if (formatTest.Int64NegativeExclusiveOption.IsSet)
- writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ if (formatTest.Int64NegativeExclusiveOption.Value != null)
+ writer.WriteNumber("int64NegativeExclusive", formatTest.Int64NegativeExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64NegativeExclusive");
if (formatTest.Int64PositiveOption.IsSet)
- writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ if (formatTest.Int64PositiveOption.Value != null)
+ writer.WriteNumber("int64Positive", formatTest.Int64PositiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64Positive");
if (formatTest.Int64PositiveExclusiveOption.IsSet)
- writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ if (formatTest.Int64PositiveExclusiveOption.Value != null)
+ writer.WriteNumber("int64PositiveExclusive", formatTest.Int64PositiveExclusiveOption.Value!.Value);
+ else
+ writer.WriteNull("int64PositiveExclusive");
if (formatTest.IntegerOption.IsSet)
- writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ if (formatTest.IntegerOption.Value != null)
+ writer.WriteNumber("integer", formatTest.IntegerOption.Value!.Value);
+ else
+ writer.WriteNull("integer");
if (formatTest.PatternWithBackslashOption.IsSet)
writer.WriteString("pattern_with_backslash", formatTest.PatternWithBackslash);
@@ -1043,16 +986,28 @@ public void WriteProperties(Utf8JsonWriter writer, FormatTest formatTest, JsonSe
writer.WriteString("string", formatTest.String);
if (formatTest.StringFormattedAsDecimalOption.IsSet)
- writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ if (formatTest.StringFormattedAsDecimalOption.Value != null)
+ writer.WriteString("string_formatted_as_decimal", formatTest.StringFormattedAsDecimal.ToString());
+ else
+ writer.WriteNull("string_formatted_as_decimal");
if (formatTest.UnsignedIntegerOption.IsSet)
- writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ if (formatTest.UnsignedIntegerOption.Value != null)
+ writer.WriteNumber("unsigned_integer", formatTest.UnsignedIntegerOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_integer");
if (formatTest.UnsignedLongOption.IsSet)
- writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ if (formatTest.UnsignedLongOption.Value != null)
+ writer.WriteNumber("unsigned_long", formatTest.UnsignedLongOption.Value!.Value);
+ else
+ writer.WriteNull("unsigned_long");
if (formatTest.UuidOption.IsSet)
- writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ if (formatTest.UuidOption.Value != null)
+ writer.WriteString("uuid", formatTest.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
index 6aa166222089..de97c93e546a 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Fruit.cs
@@ -175,9 +175,6 @@ public override Fruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class Fruit.");
-
if (apple != null)
return new Fruit(apple, color);
@@ -211,9 +208,6 @@ public override void Write(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOpt
///
public void WriteProperties(Utf8JsonWriter writer, Fruit fruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (fruit.ColorOption.IsSet && fruit.Color == null)
- throw new ArgumentNullException(nameof(fruit.Color), "Property is required for class Fruit.");
-
if (fruit.ColorOption.IsSet)
writer.WriteString("color", fruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
index 8b41879612ea..b13b4b826059 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/GmFruit.cs
@@ -179,9 +179,6 @@ public override GmFruit Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (color.IsSet && color.Value == null)
- throw new ArgumentNullException(nameof(color), "Property is not nullable for class GmFruit.");
-
Option appleParsedValue = apple == null
? default
: new Option(apple);
@@ -228,9 +225,6 @@ public override void Write(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, GmFruit gmFruit, JsonSerializerOptions jsonSerializerOptions)
{
- if (gmFruit.ColorOption.IsSet && gmFruit.Color == null)
- throw new ArgumentNullException(nameof(gmFruit.Color), "Property is required for class GmFruit.");
-
if (gmFruit.ColorOption.IsSet)
writer.WriteString("color", gmFruit.Color);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
index 0bf77a18dca2..680d39774424 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/HasOnlyReadOnly.cs
@@ -198,12 +198,6 @@ public override HasOnlyReadOnly Read(ref Utf8JsonReader utf8JsonReader, Type typ
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class HasOnlyReadOnly.");
-
- if (foo.IsSet && foo.Value == null)
- throw new ArgumentNullException(nameof(foo), "Property is not nullable for class HasOnlyReadOnly.");
-
return new HasOnlyReadOnly(bar, foo);
}
@@ -231,12 +225,6 @@ public override void Write(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnl
///
public void WriteProperties(Utf8JsonWriter writer, HasOnlyReadOnly hasOnlyReadOnly, JsonSerializerOptions jsonSerializerOptions)
{
- if (hasOnlyReadOnly.BarOption.IsSet && hasOnlyReadOnly.Bar == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Bar), "Property is required for class HasOnlyReadOnly.");
-
- if (hasOnlyReadOnly.FooOption.IsSet && hasOnlyReadOnly.Foo == null)
- throw new ArgumentNullException(nameof(hasOnlyReadOnly.Foo), "Property is required for class HasOnlyReadOnly.");
-
if (hasOnlyReadOnly.BarOption.IsSet)
writer.WriteString("bar", hasOnlyReadOnly.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/List.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
index 024998ed763a..a15f8babfebd 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/List.cs
@@ -137,9 +137,6 @@ public override List Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (var123List.IsSet && var123List.Value == null)
- throw new ArgumentNullException(nameof(var123List), "Property is not nullable for class List.");
-
return new List(var123List);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, List list, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, List list, JsonSerializerOptions jsonSerializerOptions)
{
- if (list.Var123ListOption.IsSet && list.Var123List == null)
- throw new ArgumentNullException(nameof(list.Var123List), "Property is required for class List.");
-
if (list.Var123ListOption.IsSet)
writer.WriteString("123-list", list.Var123List);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
index e54eebdaa1dc..bfefac8c977f 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/LiteralStringClass.cs
@@ -157,12 +157,6 @@ public override LiteralStringClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (escapedLiteralString.IsSet && escapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(escapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
- if (unescapedLiteralString.IsSet && unescapedLiteralString.Value == null)
- throw new ArgumentNullException(nameof(unescapedLiteralString), "Property is not nullable for class LiteralStringClass.");
-
return new LiteralStringClass(escapedLiteralString, unescapedLiteralString);
}
@@ -190,12 +184,6 @@ public override void Write(Utf8JsonWriter writer, LiteralStringClass literalStri
///
public void WriteProperties(Utf8JsonWriter writer, LiteralStringClass literalStringClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (literalStringClass.EscapedLiteralStringOption.IsSet && literalStringClass.EscapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.EscapedLiteralString), "Property is required for class LiteralStringClass.");
-
- if (literalStringClass.UnescapedLiteralStringOption.IsSet && literalStringClass.UnescapedLiteralString == null)
- throw new ArgumentNullException(nameof(literalStringClass.UnescapedLiteralString), "Property is required for class LiteralStringClass.");
-
if (literalStringClass.EscapedLiteralStringOption.IsSet)
writer.WriteString("escapedLiteralString", literalStringClass.EscapedLiteralString);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
index 40dee3f15569..775fe4599442 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MapTest.cs
@@ -263,18 +263,6 @@ public override MapTest Read(ref Utf8JsonReader utf8JsonReader, Type typeToConve
}
}
- if (directMap.IsSet && directMap.Value == null)
- throw new ArgumentNullException(nameof(directMap), "Property is not nullable for class MapTest.");
-
- if (indirectMap.IsSet && indirectMap.Value == null)
- throw new ArgumentNullException(nameof(indirectMap), "Property is not nullable for class MapTest.");
-
- if (mapMapOfString.IsSet && mapMapOfString.Value == null)
- throw new ArgumentNullException(nameof(mapMapOfString), "Property is not nullable for class MapTest.");
-
- if (mapOfEnumString.IsSet && mapOfEnumString.Value == null)
- throw new ArgumentNullException(nameof(mapOfEnumString), "Property is not nullable for class MapTest.");
-
return new MapTest(directMap, indirectMap, mapMapOfString, mapOfEnumString);
}
@@ -302,18 +290,6 @@ public override void Write(Utf8JsonWriter writer, MapTest mapTest, JsonSerialize
///
public void WriteProperties(Utf8JsonWriter writer, MapTest mapTest, JsonSerializerOptions jsonSerializerOptions)
{
- if (mapTest.DirectMapOption.IsSet && mapTest.DirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.DirectMap), "Property is required for class MapTest.");
-
- if (mapTest.IndirectMapOption.IsSet && mapTest.IndirectMap == null)
- throw new ArgumentNullException(nameof(mapTest.IndirectMap), "Property is required for class MapTest.");
-
- if (mapTest.MapMapOfStringOption.IsSet && mapTest.MapMapOfString == null)
- throw new ArgumentNullException(nameof(mapTest.MapMapOfString), "Property is required for class MapTest.");
-
- if (mapTest.MapOfEnumStringOption.IsSet && mapTest.MapOfEnumString == null)
- throw new ArgumentNullException(nameof(mapTest.MapOfEnumString), "Property is required for class MapTest.");
-
if (mapTest.DirectMapOption.IsSet)
{
writer.WritePropertyName("direct_map");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
index cdac03c3bcf4..b7562da53ca1 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedAnyOf.cs
@@ -137,9 +137,6 @@ public override MixedAnyOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedAnyOf.");
-
return new MixedAnyOf(content);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedAnyOf mixedAnyOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedAnyOf.ContentOption.IsSet && mixedAnyOf.Content == null)
- throw new ArgumentNullException(nameof(mixedAnyOf.Content), "Property is required for class MixedAnyOf.");
-
if (mixedAnyOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
index e9f36662dd80..cf8a31520783 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedOneOf.cs
@@ -137,9 +137,6 @@ public override MixedOneOf Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (content.IsSet && content.Value == null)
- throw new ArgumentNullException(nameof(content), "Property is not nullable for class MixedOneOf.");
-
return new MixedOneOf(content);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedOneOf mixedOneOf, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedOneOf.ContentOption.IsSet && mixedOneOf.Content == null)
- throw new ArgumentNullException(nameof(mixedOneOf.Content), "Property is required for class MixedOneOf.");
-
if (mixedOneOf.ContentOption.IsSet)
{
writer.WritePropertyName("content");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
index 3629d644571b..fcfbae83d506 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedPropertiesAndAdditionalPropertiesClass.cs
@@ -209,18 +209,6 @@ public override MixedPropertiesAndAdditionalPropertiesClass Read(ref Utf8JsonRea
}
}
- if (dateTime.IsSet && dateTime.Value == null)
- throw new ArgumentNullException(nameof(dateTime), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (map.IsSet && map.Value == null)
- throw new ArgumentNullException(nameof(map), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
- if (uuidWithPattern.IsSet && uuidWithPattern.Value == null)
- throw new ArgumentNullException(nameof(uuidWithPattern), "Property is not nullable for class MixedPropertiesAndAdditionalPropertiesClass.");
-
return new MixedPropertiesAndAdditionalPropertiesClass(dateTime, map, uuid, uuidWithPattern);
}
@@ -248,11 +236,11 @@ public override void Write(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet && mixedPropertiesAndAdditionalPropertiesClass.Map == null)
- throw new ArgumentNullException(nameof(mixedPropertiesAndAdditionalPropertiesClass.Map), "Property is required for class MixedPropertiesAndAdditionalPropertiesClass.");
-
if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.IsSet)
- writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ if (mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value != null)
+ writer.WriteString("dateTime", mixedPropertiesAndAdditionalPropertiesClass.DateTimeOption.Value!.Value.ToString(DateTimeFormat));
+ else
+ writer.WriteNull("dateTime");
if (mixedPropertiesAndAdditionalPropertiesClass.MapOption.IsSet)
{
@@ -260,10 +248,16 @@ public void WriteProperties(Utf8JsonWriter writer, MixedPropertiesAndAdditionalP
JsonSerializer.Serialize(writer, mixedPropertiesAndAdditionalPropertiesClass.Map, jsonSerializerOptions);
}
if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.IsSet)
- writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value != null)
+ writer.WriteString("uuid", mixedPropertiesAndAdditionalPropertiesClass.UuidOption.Value!.Value);
+ else
+ writer.WriteNull("uuid");
if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.IsSet)
- writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ if (mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value != null)
+ writer.WriteString("uuid_with_pattern", mixedPropertiesAndAdditionalPropertiesClass.UuidWithPatternOption.Value!.Value);
+ else
+ writer.WriteNull("uuid_with_pattern");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
index 696681a920f3..daae5ac2d835 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/MixedSubId.cs
@@ -137,9 +137,6 @@ public override MixedSubId Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class MixedSubId.");
-
return new MixedSubId(id);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, MixedSubId mixedSubId, JsonSerializerOptions jsonSerializerOptions)
{
- if (mixedSubId.IdOption.IsSet && mixedSubId.Id == null)
- throw new ArgumentNullException(nameof(mixedSubId.Id), "Property is required for class MixedSubId.");
-
if (mixedSubId.IdOption.IsSet)
writer.WriteString("id", mixedSubId.Id);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
index 4b3f421263d4..bf378de647bc 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Model200Response.cs
@@ -157,12 +157,6 @@ public override Model200Response Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varClass.IsSet && varClass.Value == null)
- throw new ArgumentNullException(nameof(varClass), "Property is not nullable for class Model200Response.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Model200Response.");
-
return new Model200Response(varClass, name);
}
@@ -190,14 +184,14 @@ public override void Write(Utf8JsonWriter writer, Model200Response model200Respo
///
public void WriteProperties(Utf8JsonWriter writer, Model200Response model200Response, JsonSerializerOptions jsonSerializerOptions)
{
- if (model200Response.ClassOption.IsSet && model200Response.Class == null)
- throw new ArgumentNullException(nameof(model200Response.Class), "Property is required for class Model200Response.");
-
if (model200Response.ClassOption.IsSet)
writer.WriteString("class", model200Response.Class);
if (model200Response.NameOption.IsSet)
- writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ if (model200Response.NameOption.Value != null)
+ writer.WriteNumber("name", model200Response.NameOption.Value!.Value);
+ else
+ writer.WriteNull("name");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
index 49dcb68c571f..06d54d89c068 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ModelClient.cs
@@ -137,9 +137,6 @@ public override ModelClient Read(ref Utf8JsonReader utf8JsonReader, Type typeToC
}
}
- if (varClient.IsSet && varClient.Value == null)
- throw new ArgumentNullException(nameof(varClient), "Property is not nullable for class ModelClient.");
-
return new ModelClient(varClient);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, ModelClient modelClient, JsonS
///
public void WriteProperties(Utf8JsonWriter writer, ModelClient modelClient, JsonSerializerOptions jsonSerializerOptions)
{
- if (modelClient.VarClientOption.IsSet && modelClient.VarClient == null)
- throw new ArgumentNullException(nameof(modelClient.VarClient), "Property is required for class ModelClient.");
-
if (modelClient.VarClientOption.IsSet)
writer.WriteString("client", modelClient.VarClient);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
index 72938274943d..9536a8c463c1 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Name.cs
@@ -237,15 +237,6 @@ public override Name Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (varName.IsSet && varName.Value == null)
throw new ArgumentNullException(nameof(varName), "Property is not nullable for class Name.");
- if (property.IsSet && property.Value == null)
- throw new ArgumentNullException(nameof(property), "Property is not nullable for class Name.");
-
- if (snakeCase.IsSet && snakeCase.Value == null)
- throw new ArgumentNullException(nameof(snakeCase), "Property is not nullable for class Name.");
-
- if (var123Number.IsSet && var123Number.Value == null)
- throw new ArgumentNullException(nameof(var123Number), "Property is not nullable for class Name.");
-
return new Name(varName.Value!.Value!, property, snakeCase, var123Number);
}
@@ -273,19 +264,22 @@ public override void Write(Utf8JsonWriter writer, Name name, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, Name name, JsonSerializerOptions jsonSerializerOptions)
{
- if (name.PropertyOption.IsSet && name.Property == null)
- throw new ArgumentNullException(nameof(name.Property), "Property is required for class Name.");
-
writer.WriteNumber("name", name.VarName);
if (name.PropertyOption.IsSet)
writer.WriteString("property", name.Property);
if (name.SnakeCaseOption.IsSet)
- writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ if (name.SnakeCaseOption.Value != null)
+ writer.WriteNumber("snake_case", name.SnakeCaseOption.Value!.Value);
+ else
+ writer.WriteNull("snake_case");
if (name.Var123NumberOption.IsSet)
- writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ if (name.Var123NumberOption.Value != null)
+ writer.WriteNumber("123Number", name.Var123NumberOption.Value!.Value);
+ else
+ writer.WriteNull("123Number");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
index aa2baca6ee31..0158c4f696ad 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NullableClass.cs
@@ -367,12 +367,6 @@ public override NullableClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (arrayItemsNullable.IsSet && arrayItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(arrayItemsNullable), "Property is not nullable for class NullableClass.");
-
- if (objectItemsNullable.IsSet && objectItemsNullable.Value == null)
- throw new ArgumentNullException(nameof(objectItemsNullable), "Property is not nullable for class NullableClass.");
-
return new NullableClass(arrayAndItemsNullableProp, arrayItemsNullable, arrayNullableProp, booleanProp, dateProp, datetimeProp, integerProp, numberProp, objectAndItemsNullableProp, objectItemsNullable, objectNullableProp, stringProp);
}
@@ -400,12 +394,6 @@ public override void Write(Utf8JsonWriter writer, NullableClass nullableClass, J
///
public void WriteProperties(Utf8JsonWriter writer, NullableClass nullableClass, JsonSerializerOptions jsonSerializerOptions)
{
- if (nullableClass.ArrayItemsNullableOption.IsSet && nullableClass.ArrayItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ArrayItemsNullable), "Property is required for class NullableClass.");
-
- if (nullableClass.ObjectItemsNullableOption.IsSet && nullableClass.ObjectItemsNullable == null)
- throw new ArgumentNullException(nameof(nullableClass.ObjectItemsNullable), "Property is required for class NullableClass.");
-
if (nullableClass.ArrayAndItemsNullablePropOption.IsSet)
if (nullableClass.ArrayAndItemsNullablePropOption.Value != null)
{
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
index 3662647e6562..0604d74f5677 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/NumberOnly.cs
@@ -137,9 +137,6 @@ public override NumberOnly Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (justNumber.IsSet && justNumber.Value == null)
- throw new ArgumentNullException(nameof(justNumber), "Property is not nullable for class NumberOnly.");
-
return new NumberOnly(justNumber);
}
@@ -168,7 +165,10 @@ public override void Write(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSer
public void WriteProperties(Utf8JsonWriter writer, NumberOnly numberOnly, JsonSerializerOptions jsonSerializerOptions)
{
if (numberOnly.JustNumberOption.IsSet)
- writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ if (numberOnly.JustNumberOption.Value != null)
+ writer.WriteNumber("JustNumber", numberOnly.JustNumberOption.Value!.Value);
+ else
+ writer.WriteNull("JustNumber");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
index b2fced877576..d0146bbf4380 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ObjectWithDeprecatedFields.cs
@@ -200,18 +200,6 @@ public override ObjectWithDeprecatedFields Read(ref Utf8JsonReader utf8JsonReade
}
}
- if (bars.IsSet && bars.Value == null)
- throw new ArgumentNullException(nameof(bars), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (deprecatedRef.IsSet && deprecatedRef.Value == null)
- throw new ArgumentNullException(nameof(deprecatedRef), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class ObjectWithDeprecatedFields.");
-
return new ObjectWithDeprecatedFields(bars, deprecatedRef, id, uuid);
}
@@ -239,15 +227,6 @@ public override void Write(Utf8JsonWriter writer, ObjectWithDeprecatedFields obj
///
public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields objectWithDeprecatedFields, JsonSerializerOptions jsonSerializerOptions)
{
- if (objectWithDeprecatedFields.BarsOption.IsSet && objectWithDeprecatedFields.Bars == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Bars), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.DeprecatedRefOption.IsSet && objectWithDeprecatedFields.DeprecatedRef == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.DeprecatedRef), "Property is required for class ObjectWithDeprecatedFields.");
-
- if (objectWithDeprecatedFields.UuidOption.IsSet && objectWithDeprecatedFields.Uuid == null)
- throw new ArgumentNullException(nameof(objectWithDeprecatedFields.Uuid), "Property is required for class ObjectWithDeprecatedFields.");
-
if (objectWithDeprecatedFields.BarsOption.IsSet)
{
writer.WritePropertyName("bars");
@@ -259,7 +238,10 @@ public void WriteProperties(Utf8JsonWriter writer, ObjectWithDeprecatedFields ob
JsonSerializer.Serialize(writer, objectWithDeprecatedFields.DeprecatedRef, jsonSerializerOptions);
}
if (objectWithDeprecatedFields.IdOption.IsSet)
- writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ if (objectWithDeprecatedFields.IdOption.Value != null)
+ writer.WriteNumber("id", objectWithDeprecatedFields.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (objectWithDeprecatedFields.UuidOption.IsSet)
writer.WriteString("uuid", objectWithDeprecatedFields.Uuid);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
index fff55dc03b4b..22adf3949caf 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Order.cs
@@ -327,24 +327,6 @@ public override Order Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
}
}
- if (complete.IsSet && complete.Value == null)
- throw new ArgumentNullException(nameof(complete), "Property is not nullable for class Order.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Order.");
-
- if (petId.IsSet && petId.Value == null)
- throw new ArgumentNullException(nameof(petId), "Property is not nullable for class Order.");
-
- if (quantity.IsSet && quantity.Value == null)
- throw new ArgumentNullException(nameof(quantity), "Property is not nullable for class Order.");
-
- if (shipDate.IsSet && shipDate.Value == null)
- throw new ArgumentNullException(nameof(shipDate), "Property is not nullable for class Order.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Order.");
-
return new Order(complete, id, petId, quantity, shipDate, status);
}
@@ -373,19 +355,34 @@ public override void Write(Utf8JsonWriter writer, Order order, JsonSerializerOpt
public void WriteProperties(Utf8JsonWriter writer, Order order, JsonSerializerOptions jsonSerializerOptions)
{
if (order.CompleteOption.IsSet)
- writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ if (order.CompleteOption.Value != null)
+ writer.WriteBoolean("complete", order.CompleteOption.Value!.Value);
+ else
+ writer.WriteNull("complete");
if (order.IdOption.IsSet)
- writer.WriteNumber("id", order.IdOption.Value!.Value);
+ if (order.IdOption.Value != null)
+ writer.WriteNumber("id", order.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (order.PetIdOption.IsSet)
- writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ if (order.PetIdOption.Value != null)
+ writer.WriteNumber("petId", order.PetIdOption.Value!.Value);
+ else
+ writer.WriteNull("petId");
if (order.QuantityOption.IsSet)
- writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ if (order.QuantityOption.Value != null)
+ writer.WriteNumber("quantity", order.QuantityOption.Value!.Value);
+ else
+ writer.WriteNull("quantity");
if (order.ShipDateOption.IsSet)
- writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ if (order.ShipDateOption.Value != null)
+ writer.WriteString("shipDate", order.ShipDateOption.Value!.Value.ToString(ShipDateFormat));
+ else
+ writer.WriteNull("shipDate");
var statusRawValue = Order.StatusEnumToJsonValue(order.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
index 834a7f3516f1..77807c15742c 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/OuterComposite.cs
@@ -177,15 +177,6 @@ public override OuterComposite Read(ref Utf8JsonReader utf8JsonReader, Type type
}
}
- if (myBoolean.IsSet && myBoolean.Value == null)
- throw new ArgumentNullException(nameof(myBoolean), "Property is not nullable for class OuterComposite.");
-
- if (myNumber.IsSet && myNumber.Value == null)
- throw new ArgumentNullException(nameof(myNumber), "Property is not nullable for class OuterComposite.");
-
- if (myString.IsSet && myString.Value == null)
- throw new ArgumentNullException(nameof(myString), "Property is not nullable for class OuterComposite.");
-
return new OuterComposite(myBoolean, myNumber, myString);
}
@@ -213,14 +204,17 @@ public override void Write(Utf8JsonWriter writer, OuterComposite outerComposite,
///
public void WriteProperties(Utf8JsonWriter writer, OuterComposite outerComposite, JsonSerializerOptions jsonSerializerOptions)
{
- if (outerComposite.MyStringOption.IsSet && outerComposite.MyString == null)
- throw new ArgumentNullException(nameof(outerComposite.MyString), "Property is required for class OuterComposite.");
-
if (outerComposite.MyBooleanOption.IsSet)
- writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ if (outerComposite.MyBooleanOption.Value != null)
+ writer.WriteBoolean("my_boolean", outerComposite.MyBooleanOption.Value!.Value);
+ else
+ writer.WriteNull("my_boolean");
if (outerComposite.MyNumberOption.IsSet)
- writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ if (outerComposite.MyNumberOption.Value != null)
+ writer.WriteNumber("my_number", outerComposite.MyNumberOption.Value!.Value);
+ else
+ writer.WriteNull("my_number");
if (outerComposite.MyStringOption.IsSet)
writer.WriteString("my_string", outerComposite.MyString);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
index fc68eb27a177..8dafe7f105ae 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Pet.cs
@@ -320,18 +320,6 @@ public override Pet Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
if (photoUrls.IsSet && photoUrls.Value == null)
throw new ArgumentNullException(nameof(photoUrls), "Property is not nullable for class Pet.");
- if (category.IsSet && category.Value == null)
- throw new ArgumentNullException(nameof(category), "Property is not nullable for class Pet.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Pet.");
-
- if (status.IsSet && status.Value == null)
- throw new ArgumentNullException(nameof(status), "Property is not nullable for class Pet.");
-
- if (tags.IsSet && tags.Value == null)
- throw new ArgumentNullException(nameof(tags), "Property is not nullable for class Pet.");
-
return new Pet(name.Value!, photoUrls.Value!, category, id, status, tags);
}
@@ -365,12 +353,6 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
if (pet.PhotoUrls == null)
throw new ArgumentNullException(nameof(pet.PhotoUrls), "Property is required for class Pet.");
- if (pet.CategoryOption.IsSet && pet.Category == null)
- throw new ArgumentNullException(nameof(pet.Category), "Property is required for class Pet.");
-
- if (pet.TagsOption.IsSet && pet.Tags == null)
- throw new ArgumentNullException(nameof(pet.Tags), "Property is required for class Pet.");
-
writer.WriteString("name", pet.Name);
writer.WritePropertyName("photoUrls");
@@ -381,7 +363,10 @@ public void WriteProperties(Utf8JsonWriter writer, Pet pet, JsonSerializerOption
JsonSerializer.Serialize(writer, pet.Category, jsonSerializerOptions);
}
if (pet.IdOption.IsSet)
- writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ if (pet.IdOption.Value != null)
+ writer.WriteNumber("id", pet.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
var statusRawValue = Pet.StatusEnumToJsonValue(pet.StatusOption.Value!.Value);
writer.WriteString("status", statusRawValue);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
index 4d458434bb1c..cf6451028c6e 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ReadOnlyFirst.cs
@@ -195,12 +195,6 @@ public override ReadOnlyFirst Read(ref Utf8JsonReader utf8JsonReader, Type typeT
}
}
- if (bar.IsSet && bar.Value == null)
- throw new ArgumentNullException(nameof(bar), "Property is not nullable for class ReadOnlyFirst.");
-
- if (baz.IsSet && baz.Value == null)
- throw new ArgumentNullException(nameof(baz), "Property is not nullable for class ReadOnlyFirst.");
-
return new ReadOnlyFirst(bar, baz);
}
@@ -228,12 +222,6 @@ public override void Write(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, J
///
public void WriteProperties(Utf8JsonWriter writer, ReadOnlyFirst readOnlyFirst, JsonSerializerOptions jsonSerializerOptions)
{
- if (readOnlyFirst.BarOption.IsSet && readOnlyFirst.Bar == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Bar), "Property is required for class ReadOnlyFirst.");
-
- if (readOnlyFirst.BazOption.IsSet && readOnlyFirst.Baz == null)
- throw new ArgumentNullException(nameof(readOnlyFirst.Baz), "Property is required for class ReadOnlyFirst.");
-
if (readOnlyFirst.BarOption.IsSet)
writer.WriteString("bar", readOnlyFirst.Bar);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
index 074d0e77ee37..f4c4908b2237 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RequiredClass.cs
@@ -2080,39 +2080,6 @@ public override RequiredClass Read(ref Utf8JsonReader utf8JsonReader, Type typeT
if (requiredNotnullableintegerProp.IsSet && requiredNotnullableintegerProp.Value == null)
throw new ArgumentNullException(nameof(requiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
- if (notRequiredNotnullableDateProp.IsSet && notRequiredNotnullableDateProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableDateProp), "Property is not nullable for class RequiredClass.");
-
- if (notRequiredNotnullableintegerProp.IsSet && notRequiredNotnullableintegerProp.Value == null)
- throw new ArgumentNullException(nameof(notRequiredNotnullableintegerProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableArrayOfString.IsSet && notrequiredNotnullableArrayOfString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableArrayOfString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableBooleanProp.IsSet && notrequiredNotnullableBooleanProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableBooleanProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableDatetimeProp.IsSet && notrequiredNotnullableDatetimeProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableDatetimeProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumInteger.IsSet && notrequiredNotnullableEnumInteger.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumInteger), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumIntegerOnly.IsSet && notrequiredNotnullableEnumIntegerOnly.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumIntegerOnly), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableEnumString.IsSet && notrequiredNotnullableEnumString.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableEnumString), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableOuterEnumDefaultValue.IsSet && notrequiredNotnullableOuterEnumDefaultValue.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableOuterEnumDefaultValue), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableStringProp.IsSet && notrequiredNotnullableStringProp.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableStringProp), "Property is not nullable for class RequiredClass.");
-
- if (notrequiredNotnullableUuid.IsSet && notrequiredNotnullableUuid.Value == null)
- throw new ArgumentNullException(nameof(notrequiredNotnullableUuid), "Property is not nullable for class RequiredClass.");
-
return new RequiredClass(requiredNotNullableDateProp.Value!.Value!, requiredNotnullableArrayOfString.Value!, requiredNotnullableBooleanProp.Value!.Value!, requiredNotnullableDatetimeProp.Value!.Value!, requiredNotnullableEnumInteger.Value!.Value!, requiredNotnullableEnumIntegerOnly.Value!.Value!, requiredNotnullableEnumString.Value!.Value!, requiredNotnullableOuterEnumDefaultValue.Value!.Value!, requiredNotnullableStringProp.Value!, requiredNotnullableUuid.Value!.Value!, requiredNotnullableintegerProp.Value!.Value!, notRequiredNotnullableDateProp, notRequiredNotnullableintegerProp, notRequiredNullableDateProp, notRequiredNullableIntegerProp, notrequiredNotnullableArrayOfString, notrequiredNotnullableBooleanProp, notrequiredNotnullableDatetimeProp, notrequiredNotnullableEnumInteger, notrequiredNotnullableEnumIntegerOnly, notrequiredNotnullableEnumString, notrequiredNotnullableOuterEnumDefaultValue, notrequiredNotnullableStringProp, notrequiredNotnullableUuid, notrequiredNullableArrayOfString, notrequiredNullableBooleanProp, notrequiredNullableDatetimeProp, notrequiredNullableEnumInteger, notrequiredNullableEnumIntegerOnly, notrequiredNullableEnumString, notrequiredNullableOuterEnumDefaultValue, notrequiredNullableStringProp, notrequiredNullableUuid, requiredNullableArrayOfString.Value!, requiredNullableBooleanProp.Value!, requiredNullableDateProp.Value!, requiredNullableDatetimeProp.Value!, requiredNullableEnumInteger.Value!, requiredNullableEnumIntegerOnly.Value!, requiredNullableEnumString.Value!, requiredNullableIntegerProp.Value!, requiredNullableOuterEnumDefaultValue.Value!, requiredNullableStringProp.Value!, requiredNullableUuid.Value!);
}
@@ -2146,12 +2113,6 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
if (requiredClass.RequiredNotnullableStringProp == null)
throw new ArgumentNullException(nameof(requiredClass.RequiredNotnullableStringProp), "Property is required for class RequiredClass.");
- if (requiredClass.NotrequiredNotnullableArrayOfStringOption.IsSet && requiredClass.NotrequiredNotnullableArrayOfString == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableArrayOfString), "Property is required for class RequiredClass.");
-
- if (requiredClass.NotrequiredNotnullableStringPropOption.IsSet && requiredClass.NotrequiredNotnullableStringProp == null)
- throw new ArgumentNullException(nameof(requiredClass.NotrequiredNotnullableStringProp), "Property is required for class RequiredClass.");
-
writer.WriteString("required_not_nullable_date_prop", requiredClass.RequiredNotNullableDateProp.ToString(RequiredNotNullableDatePropFormat));
writer.WritePropertyName("required_notnullable_array_of_string");
@@ -2176,10 +2137,16 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteNumber("required_notnullableinteger_prop", requiredClass.RequiredNotnullableintegerProp);
if (requiredClass.NotRequiredNotnullableDatePropOption.IsSet)
- writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ if (requiredClass.NotRequiredNotnullableDatePropOption.Value != null)
+ writer.WriteString("not_required_notnullable_date_prop", requiredClass.NotRequiredNotnullableDatePropOption.Value!.Value.ToString(NotRequiredNotnullableDatePropFormat));
+ else
+ writer.WriteNull("not_required_notnullable_date_prop");
if (requiredClass.NotRequiredNotnullableintegerPropOption.IsSet)
- writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ if (requiredClass.NotRequiredNotnullableintegerPropOption.Value != null)
+ writer.WriteNumber("not_required_notnullableinteger_prop", requiredClass.NotRequiredNotnullableintegerPropOption.Value!.Value);
+ else
+ writer.WriteNull("not_required_notnullableinteger_prop");
if (requiredClass.NotRequiredNullableDatePropOption.IsSet)
if (requiredClass.NotRequiredNullableDatePropOption.Value != null)
@@ -2199,16 +2166,28 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
JsonSerializer.Serialize(writer, requiredClass.NotrequiredNotnullableArrayOfString, jsonSerializerOptions);
}
if (requiredClass.NotrequiredNotnullableBooleanPropOption.IsSet)
- writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableBooleanPropOption.Value != null)
+ writer.WriteBoolean("notrequired_notnullable_boolean_prop", requiredClass.NotrequiredNotnullableBooleanPropOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_boolean_prop");
if (requiredClass.NotrequiredNotnullableDatetimePropOption.IsSet)
- writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ if (requiredClass.NotrequiredNotnullableDatetimePropOption.Value != null)
+ writer.WriteString("notrequired_notnullable_datetime_prop", requiredClass.NotrequiredNotnullableDatetimePropOption.Value!.Value.ToString(NotrequiredNotnullableDatetimePropFormat));
+ else
+ writer.WriteNull("notrequired_notnullable_datetime_prop");
if (requiredClass.NotrequiredNotnullableEnumIntegerOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer", RequiredClass.NotrequiredNotnullableEnumIntegerEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer");
if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.IsSet)
- writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ if (requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value != null)
+ writer.WriteNumber("notrequired_notnullable_enum_integer_only", RequiredClass.NotrequiredNotnullableEnumIntegerOnlyEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumIntegerOnlyOption.Value!.Value));
+ else
+ writer.WriteNull("notrequired_notnullable_enum_integer_only");
var notrequiredNotnullableEnumStringRawValue = RequiredClass.NotrequiredNotnullableEnumStringEnumToJsonValue(requiredClass.NotrequiredNotnullableEnumStringOption.Value!.Value);
writer.WriteString("notrequired_notnullable_enum_string", notrequiredNotnullableEnumStringRawValue);
@@ -2221,7 +2200,10 @@ public void WriteProperties(Utf8JsonWriter writer, RequiredClass requiredClass,
writer.WriteString("notrequired_notnullable_string_prop", requiredClass.NotrequiredNotnullableStringProp);
if (requiredClass.NotrequiredNotnullableUuidOption.IsSet)
- writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ if (requiredClass.NotrequiredNotnullableUuidOption.Value != null)
+ writer.WriteString("notrequired_notnullable_uuid", requiredClass.NotrequiredNotnullableUuidOption.Value!.Value);
+ else
+ writer.WriteNull("notrequired_notnullable_uuid");
if (requiredClass.NotrequiredNullableArrayOfStringOption.IsSet)
if (requiredClass.NotrequiredNullableArrayOfStringOption.Value != null)
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
index 1c1f18fd1dec..5ce641729926 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Result.cs
@@ -180,15 +180,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class Result.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result.");
-
return new Result(code, data, uuid);
}
@@ -216,15 +207,6 @@ public override void Write(Utf8JsonWriter writer, Result result, JsonSerializerO
///
public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializerOptions jsonSerializerOptions)
{
- if (result.CodeOption.IsSet && result.Code == null)
- throw new ArgumentNullException(nameof(result.Code), "Property is required for class Result.");
-
- if (result.DataOption.IsSet && result.Data == null)
- throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
-
- if (result.UuidOption.IsSet && result.Uuid == null)
- throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
-
if (result.CodeOption.IsSet)
writer.WriteString("code", result.Code);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
index 1544a23710c1..81617782b527 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Return.cs
@@ -192,12 +192,6 @@ public override Return Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
if (varLock.IsSet && varLock.Value == null)
throw new ArgumentNullException(nameof(varLock), "Property is not nullable for class Return.");
- if (varReturn.IsSet && varReturn.Value == null)
- throw new ArgumentNullException(nameof(varReturn), "Property is not nullable for class Return.");
-
- if (varUnsafe.IsSet && varUnsafe.Value == null)
- throw new ArgumentNullException(nameof(varUnsafe), "Property is not nullable for class Return.");
-
return new Return(varLock.Value!, varAbstract.Value!, varReturn, varUnsafe);
}
@@ -228,9 +222,6 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
if (varReturn.Lock == null)
throw new ArgumentNullException(nameof(varReturn.Lock), "Property is required for class Return.");
- if (varReturn.UnsafeOption.IsSet && varReturn.Unsafe == null)
- throw new ArgumentNullException(nameof(varReturn.Unsafe), "Property is required for class Return.");
-
writer.WriteString("lock", varReturn.Lock);
if (varReturn.Abstract != null)
@@ -239,7 +230,10 @@ public void WriteProperties(Utf8JsonWriter writer, Return varReturn, JsonSeriali
writer.WriteNull("abstract");
if (varReturn.VarReturnOption.IsSet)
- writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ if (varReturn.VarReturnOption.Value != null)
+ writer.WriteNumber("return", varReturn.VarReturnOption.Value!.Value);
+ else
+ writer.WriteNull("return");
if (varReturn.UnsafeOption.IsSet)
writer.WriteString("unsafe", varReturn.Unsafe);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
index 28b65b24ecf3..782fe80540e1 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHash.cs
@@ -157,12 +157,6 @@ public override RolesReportsHash Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (role.IsSet && role.Value == null)
- throw new ArgumentNullException(nameof(role), "Property is not nullable for class RolesReportsHash.");
-
- if (roleUuid.IsSet && roleUuid.Value == null)
- throw new ArgumentNullException(nameof(roleUuid), "Property is not nullable for class RolesReportsHash.");
-
return new RolesReportsHash(role, roleUuid);
}
@@ -190,16 +184,16 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHash rolesReportsH
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHash rolesReportsHash, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHash.RoleOption.IsSet && rolesReportsHash.Role == null)
- throw new ArgumentNullException(nameof(rolesReportsHash.Role), "Property is required for class RolesReportsHash.");
-
if (rolesReportsHash.RoleOption.IsSet)
{
writer.WritePropertyName("role");
JsonSerializer.Serialize(writer, rolesReportsHash.Role, jsonSerializerOptions);
}
if (rolesReportsHash.RoleUuidOption.IsSet)
- writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ if (rolesReportsHash.RoleUuidOption.Value != null)
+ writer.WriteString("role_uuid", rolesReportsHash.RoleUuidOption.Value!.Value);
+ else
+ writer.WriteNull("role_uuid");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
index ba4ac84d8e20..c723f857b80e 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/RolesReportsHashRole.cs
@@ -137,9 +137,6 @@ public override RolesReportsHashRole Read(ref Utf8JsonReader utf8JsonReader, Typ
}
}
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class RolesReportsHashRole.");
-
return new RolesReportsHashRole(name);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, RolesReportsHashRole rolesRepo
///
public void WriteProperties(Utf8JsonWriter writer, RolesReportsHashRole rolesReportsHashRole, JsonSerializerOptions jsonSerializerOptions)
{
- if (rolesReportsHashRole.NameOption.IsSet && rolesReportsHashRole.Name == null)
- throw new ArgumentNullException(nameof(rolesReportsHashRole.Name), "Property is required for class RolesReportsHashRole.");
-
if (rolesReportsHashRole.NameOption.IsSet)
writer.WriteString("name", rolesReportsHashRole.Name);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
index 0cf9332983fd..f054cff9e4ea 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/SpecialModelName.cs
@@ -157,12 +157,6 @@ public override SpecialModelName Read(ref Utf8JsonReader utf8JsonReader, Type ty
}
}
- if (varSpecialModelName.IsSet && varSpecialModelName.Value == null)
- throw new ArgumentNullException(nameof(varSpecialModelName), "Property is not nullable for class SpecialModelName.");
-
- if (specialPropertyName.IsSet && specialPropertyName.Value == null)
- throw new ArgumentNullException(nameof(specialPropertyName), "Property is not nullable for class SpecialModelName.");
-
return new SpecialModelName(varSpecialModelName, specialPropertyName);
}
@@ -190,14 +184,14 @@ public override void Write(Utf8JsonWriter writer, SpecialModelName specialModelN
///
public void WriteProperties(Utf8JsonWriter writer, SpecialModelName specialModelName, JsonSerializerOptions jsonSerializerOptions)
{
- if (specialModelName.VarSpecialModelNameOption.IsSet && specialModelName.VarSpecialModelName == null)
- throw new ArgumentNullException(nameof(specialModelName.VarSpecialModelName), "Property is required for class SpecialModelName.");
-
if (specialModelName.VarSpecialModelNameOption.IsSet)
writer.WriteString("_special_model.name_", specialModelName.VarSpecialModelName);
if (specialModelName.SpecialPropertyNameOption.IsSet)
- writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ if (specialModelName.SpecialPropertyNameOption.Value != null)
+ writer.WriteNumber("$special[property.name]", specialModelName.SpecialPropertyNameOption.Value!.Value);
+ else
+ writer.WriteNull("$special[property.name]");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
index a350814f2c88..a5735f5f5452 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Tag.cs
@@ -157,12 +157,6 @@ public override Tag Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class Tag.");
-
- if (name.IsSet && name.Value == null)
- throw new ArgumentNullException(nameof(name), "Property is not nullable for class Tag.");
-
return new Tag(id, name);
}
@@ -190,11 +184,11 @@ public override void Write(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions
///
public void WriteProperties(Utf8JsonWriter writer, Tag tag, JsonSerializerOptions jsonSerializerOptions)
{
- if (tag.NameOption.IsSet && tag.Name == null)
- throw new ArgumentNullException(nameof(tag.Name), "Property is required for class Tag.");
-
if (tag.IdOption.IsSet)
- writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ if (tag.IdOption.Value != null)
+ writer.WriteNumber("id", tag.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (tag.NameOption.IsSet)
writer.WriteString("name", tag.Name);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
index b5f8d88ed68d..4ffddf1d1aef 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordList.cs
@@ -137,9 +137,6 @@ public override TestCollectionEndingWithWordList Read(ref Utf8JsonReader utf8Jso
}
}
- if (value.IsSet && value.Value == null)
- throw new ArgumentNullException(nameof(value), "Property is not nullable for class TestCollectionEndingWithWordList.");
-
return new TestCollectionEndingWithWordList(value);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordList testCollectionEndingWithWordList, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordList.ValueOption.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList.Value), "Property is required for class TestCollectionEndingWithWordList.");
-
if (testCollectionEndingWithWordList.ValueOption.IsSet)
writer.WriteString("value", testCollectionEndingWithWordList.Value);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
index 37acae1c88df..d58f1e6dc695 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestCollectionEndingWithWordListObject.cs
@@ -137,9 +137,6 @@ public override TestCollectionEndingWithWordListObject Read(ref Utf8JsonReader u
}
}
- if (testCollectionEndingWithWordList.IsSet && testCollectionEndingWithWordList.Value == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordList), "Property is not nullable for class TestCollectionEndingWithWordListObject.");
-
return new TestCollectionEndingWithWordListObject(testCollectionEndingWithWordList);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestCollectionEndingWithWordLi
///
public void WriteProperties(Utf8JsonWriter writer, TestCollectionEndingWithWordListObject testCollectionEndingWithWordListObject, JsonSerializerOptions jsonSerializerOptions)
{
- if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet && testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList == null)
- throw new ArgumentNullException(nameof(testCollectionEndingWithWordListObject.TestCollectionEndingWithWordList), "Property is required for class TestCollectionEndingWithWordListObject.");
-
if (testCollectionEndingWithWordListObject.TestCollectionEndingWithWordListOption.IsSet)
{
writer.WritePropertyName("TestCollectionEndingWithWordList");
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
index de60d7c2281f..b9052313836c 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestInlineFreeformAdditionalPropertiesRequest.cs
@@ -137,9 +137,6 @@ public override TestInlineFreeformAdditionalPropertiesRequest Read(ref Utf8JsonR
}
}
- if (someProperty.IsSet && someProperty.Value == null)
- throw new ArgumentNullException(nameof(someProperty), "Property is not nullable for class TestInlineFreeformAdditionalPropertiesRequest.");
-
return new TestInlineFreeformAdditionalPropertiesRequest(someProperty);
}
@@ -167,9 +164,6 @@ public override void Write(Utf8JsonWriter writer, TestInlineFreeformAdditionalPr
///
public void WriteProperties(Utf8JsonWriter writer, TestInlineFreeformAdditionalPropertiesRequest testInlineFreeformAdditionalPropertiesRequest, JsonSerializerOptions jsonSerializerOptions)
{
- if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet && testInlineFreeformAdditionalPropertiesRequest.SomeProperty == null)
- throw new ArgumentNullException(nameof(testInlineFreeformAdditionalPropertiesRequest.SomeProperty), "Property is required for class TestInlineFreeformAdditionalPropertiesRequest.");
-
if (testInlineFreeformAdditionalPropertiesRequest.SomePropertyOption.IsSet)
writer.WriteString("someProperty", testInlineFreeformAdditionalPropertiesRequest.SomeProperty);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
index df0deacac70e..d7310e182744 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/TestResult.cs
@@ -181,15 +181,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
}
}
- if (code.IsSet && code.Value == null)
- throw new ArgumentNullException(nameof(code), "Property is not nullable for class TestResult.");
-
- if (data.IsSet && data.Value == null)
- throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult.");
-
- if (uuid.IsSet && uuid.Value == null)
- throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult.");
-
return new TestResult(code, data, uuid);
}
@@ -217,12 +208,6 @@ public override void Write(Utf8JsonWriter writer, TestResult testResult, JsonSer
///
public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSerializerOptions jsonSerializerOptions)
{
- if (testResult.DataOption.IsSet && testResult.Data == null)
- throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
-
- if (testResult.UuidOption.IsSet && testResult.Uuid == null)
- throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
-
if (testResult.CodeOption.IsSet)
{
var codeRawValue = TestResultCodeValueConverter.ToJsonValue(testResult.Code!.Value);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/User.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
index 6af3ab9df35c..4a72b6988ae5 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/User.cs
@@ -362,33 +362,6 @@ public override User Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert,
}
}
- if (email.IsSet && email.Value == null)
- throw new ArgumentNullException(nameof(email), "Property is not nullable for class User.");
-
- if (firstName.IsSet && firstName.Value == null)
- throw new ArgumentNullException(nameof(firstName), "Property is not nullable for class User.");
-
- if (id.IsSet && id.Value == null)
- throw new ArgumentNullException(nameof(id), "Property is not nullable for class User.");
-
- if (lastName.IsSet && lastName.Value == null)
- throw new ArgumentNullException(nameof(lastName), "Property is not nullable for class User.");
-
- if (objectWithNoDeclaredProps.IsSet && objectWithNoDeclaredProps.Value == null)
- throw new ArgumentNullException(nameof(objectWithNoDeclaredProps), "Property is not nullable for class User.");
-
- if (password.IsSet && password.Value == null)
- throw new ArgumentNullException(nameof(password), "Property is not nullable for class User.");
-
- if (phone.IsSet && phone.Value == null)
- throw new ArgumentNullException(nameof(phone), "Property is not nullable for class User.");
-
- if (userStatus.IsSet && userStatus.Value == null)
- throw new ArgumentNullException(nameof(userStatus), "Property is not nullable for class User.");
-
- if (username.IsSet && username.Value == null)
- throw new ArgumentNullException(nameof(username), "Property is not nullable for class User.");
-
return new User(anyTypeProp, anyTypePropNullable, email, firstName, id, lastName, objectWithNoDeclaredProps, objectWithNoDeclaredPropsNullable, password, phone, userStatus, username);
}
@@ -416,27 +389,6 @@ public override void Write(Utf8JsonWriter writer, User user, JsonSerializerOptio
///
public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOptions jsonSerializerOptions)
{
- if (user.EmailOption.IsSet && user.Email == null)
- throw new ArgumentNullException(nameof(user.Email), "Property is required for class User.");
-
- if (user.FirstNameOption.IsSet && user.FirstName == null)
- throw new ArgumentNullException(nameof(user.FirstName), "Property is required for class User.");
-
- if (user.LastNameOption.IsSet && user.LastName == null)
- throw new ArgumentNullException(nameof(user.LastName), "Property is required for class User.");
-
- if (user.ObjectWithNoDeclaredPropsOption.IsSet && user.ObjectWithNoDeclaredProps == null)
- throw new ArgumentNullException(nameof(user.ObjectWithNoDeclaredProps), "Property is required for class User.");
-
- if (user.PasswordOption.IsSet && user.Password == null)
- throw new ArgumentNullException(nameof(user.Password), "Property is required for class User.");
-
- if (user.PhoneOption.IsSet && user.Phone == null)
- throw new ArgumentNullException(nameof(user.Phone), "Property is required for class User.");
-
- if (user.UsernameOption.IsSet && user.Username == null)
- throw new ArgumentNullException(nameof(user.Username), "Property is required for class User.");
-
if (user.AnyTypePropOption.IsSet)
if (user.AnyTypePropOption.Value != null)
{
@@ -460,7 +412,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("firstName", user.FirstName);
if (user.IdOption.IsSet)
- writer.WriteNumber("id", user.IdOption.Value!.Value);
+ if (user.IdOption.Value != null)
+ writer.WriteNumber("id", user.IdOption.Value!.Value);
+ else
+ writer.WriteNull("id");
if (user.LastNameOption.IsSet)
writer.WriteString("lastName", user.LastName);
@@ -485,7 +440,10 @@ public void WriteProperties(Utf8JsonWriter writer, User user, JsonSerializerOpti
writer.WriteString("phone", user.Phone);
if (user.UserStatusOption.IsSet)
- writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ if (user.UserStatusOption.Value != null)
+ writer.WriteNumber("userStatus", user.UserStatusOption.Value!.Value);
+ else
+ writer.WriteNull("userStatus");
if (user.UsernameOption.IsSet)
writer.WriteString("username", user.Username);
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
index 080a4f804022..2aa92b38bcca 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Whale.cs
@@ -176,12 +176,6 @@ public override Whale Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Whale.");
- if (hasBaleen.IsSet && hasBaleen.Value == null)
- throw new ArgumentNullException(nameof(hasBaleen), "Property is not nullable for class Whale.");
-
- if (hasTeeth.IsSet && hasTeeth.Value == null)
- throw new ArgumentNullException(nameof(hasTeeth), "Property is not nullable for class Whale.");
-
return new Whale(className.Value!, hasBaleen, hasTeeth);
}
@@ -215,10 +209,16 @@ public void WriteProperties(Utf8JsonWriter writer, Whale whale, JsonSerializerOp
writer.WriteString("className", whale.ClassName);
if (whale.HasBaleenOption.IsSet)
- writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ if (whale.HasBaleenOption.Value != null)
+ writer.WriteBoolean("hasBaleen", whale.HasBaleenOption.Value!.Value);
+ else
+ writer.WriteNull("hasBaleen");
if (whale.HasTeethOption.IsSet)
- writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ if (whale.HasTeethOption.Value != null)
+ writer.WriteBoolean("hasTeeth", whale.HasTeethOption.Value!.Value);
+ else
+ writer.WriteNull("hasTeeth");
}
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
index 0d0e7222c42b..297c28839930 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/Zebra.cs
@@ -238,9 +238,6 @@ public override Zebra Read(ref Utf8JsonReader utf8JsonReader, Type typeToConvert
if (className.IsSet && className.Value == null)
throw new ArgumentNullException(nameof(className), "Property is not nullable for class Zebra.");
- if (type.IsSet && type.Value == null)
- throw new ArgumentNullException(nameof(type), "Property is not nullable for class Zebra.");
-
return new Zebra(className.Value!, type);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
index 74792442fd0e..8976bef3505e 100644
--- a/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
+++ b/samples/client/petstore/csharp/generichost/net9/SourceGeneration/src/Org.OpenAPITools/Model/ZeroBasedEnumClass.cs
@@ -205,9 +205,6 @@ public override ZeroBasedEnumClass Read(ref Utf8JsonReader utf8JsonReader, Type
}
}
- if (zeroBasedEnum.IsSet && zeroBasedEnum.Value == null)
- throw new ArgumentNullException(nameof(zeroBasedEnum), "Property is not nullable for class ZeroBasedEnumClass.");
-
return new ZeroBasedEnumClass(zeroBasedEnum);
}
diff --git a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
index d81a3689e6e1..d2d90cc36c59 100644
--- a/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
+++ b/samples/client/petstore/csharp/generichost/net9/UseDateTimeForDate/src/Org.OpenAPITools/Model/NowGet200Response.cs
@@ -158,12 +158,6 @@ public override NowGet200Response Read(ref Utf8JsonReader utf8JsonReader, Type t
}
}
- if (now.IsSet && now.Value == null)
- throw new ArgumentNullException(nameof(now), "Property is not nullable for class NowGet200Response.");
-
- if (today.IsSet && today.Value == null)
- throw new ArgumentNullException(nameof(today), "Property is not nullable for class NowGet200Response.");
-
return new NowGet200Response(now, today);
}
@@ -192,10 +186,16 @@ public override void Write(Utf8JsonWriter writer, NowGet200Response nowGet200Res
public void WriteProperties(Utf8JsonWriter writer, NowGet200Response nowGet200Response, JsonSerializerOptions jsonSerializerOptions)
{
if (nowGet200Response.NowOption.IsSet)
- writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
+ if (nowGet200Response.NowOption.Value != null)
+ writer.WriteString("now", nowGet200Response.NowOption.Value!.Value.ToString(NowFormat));
+ else
+ writer.WriteNull("now");
if (nowGet200Response.TodayOption.IsSet)
- writer.WriteString("today", nowGet200Response.TodayOption.Value!.Value.ToString(TodayFormat));
+ if (nowGet200Response.TodayOption.Value != null)
+ writer.WriteString("today", nowGet200Response.TodayOption.Value!.Value.ToString(TodayFormat));
+ else
+ writer.WriteNull("today");
}
}
}